Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymer.dom(parent).querySelector polyfill is broken in 0.8 #1540

Closed
zhaoz opened this issue May 14, 2015 · 4 comments
Closed

Polymer.dom(parent).querySelector polyfill is broken in 0.8 #1540

zhaoz opened this issue May 14, 2015 · 4 comments

Comments

@zhaoz
Copy link
Contributor

zhaoz commented May 14, 2015

Trying to use the polyfill and I'm currently unable to querySelector/querySelectorAll with webcomponents-lite

I get an error:
Polymer.dom(parent).querySelectorAll('*')
TypeError: undefined is not an object (evaluating 'Array.prototype.slice.call(b)')

@zhaoz zhaoz changed the title Polymer.dom(parent).querySelector is broken in 0.8 Polymer.dom(parent).querySelector polyfill is broken in 0.8 May 14, 2015
@zhaoz
Copy link
Contributor Author

zhaoz commented May 15, 2015

Note that this was in firefox.

It seems like queryselector just doesn't work at all,

Polymer.dom(this.root).querySelector('blah /deep/ blah') also produces errors.

SyntaxError: An invalid or illegal string was specified

@arthurevans
Copy link

querySelector is working fine for me.

The first error sounds like the node you're working on (parent) is undefined.

The second error is because Firefox doesn't support native shadow DOM, so it doesn't recognize /deep/ as a valid selector.

@zhaoz
Copy link
Contributor Author

zhaoz commented May 16, 2015

What would be correct way to do /deep/ selectors in firefox then? Do you detect if the browser has shadow dom support and remove the deep selector?
I guess my assumption was that Polymer.dom returns a shim object able to support deep selectors. Maybe that assumption was incorrect.

As for parent is undefined, when can that occur? window.parent points to itself by default. I also tried it again, parent is not undefined.

@sorvell
Copy link
Contributor

sorvell commented May 21, 2015

The argument to Polymer.dom must be a node. Therefore, in the original post, an error is expected unless parent is a node.

As far as /deep/, Polymer.dom's querySelector specifically does not support this. The /deep/ css selector is being removed from the ShadowDOM spec so it's not good to rely on. In cases where crawling the entire document is absolutely necessary, it can be done manually.

@sorvell sorvell closed this as completed May 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants