-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
support shadow DOM when reading element text #4230
Conversation
could anyone point me in the right direction to updating closure library? what you have in third_party doesn't look anything like any distribution of the closure library. how have we updated it in the past? can throw away the last 2 commits if there is a better way |
not quite sure whats going on with these tests... it seems the |
I haven't a clue how Closure gets updated in this repository. @jleyba, can you help out? I can have a go at the rest of the code, though. |
I think I updated closure correctly (both the lib and the compiler). However, some part of the tests seems to fail under firefox. I can't seem to reproduce locally but it happens every time in CI. It appears to be related to closure in some way but i had trouble tracking it down. |
Could I trouble you to split the Closure library updates into a separate PR, for the sake of making things easier to review and keeping functional changes separate from "routine" upgrades? |
if ((element.nodeType == goog.dom.NodeType.ELEMENT || | ||
element.nodeType == goog.dom.NodeType.DOCUMENT_FRAGMENT) && | ||
element.nodeName != 'SCRIPT' && | ||
element.nodeName != 'STYLE') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for adding 'STYLE' here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some web components have style tags in their shadow trees. Polymer is a good example of this.
So, from what I remember, we would end up with CSS in the text content result.
At this point it'll be a little difficult splitting the two. I would need to go back through the commits to see what is update-related and what is not, also making the 2nd PR dependant on the 1st PR. would it be possible at all to keep it as one? I give it a go if not but will take a little longer. |
Sorry for the inconvenience, but I would prefer that the Closure change be separate. It's for the sake of isolating the "meaningful" changes in this PR from the more routine, mechanical changes, and so that if something goes wrong with one of the changes, it's more clear which one. |
Thanks for the contribution, and sorry for the hassle! |
@juangj looks like some CI builds failed due to some executable issue... hopefully all is well though |
This adds support to
getTextContent_
for reading text from shadow DOM nodes.The following steps were added to the logic here:
<slot>
(v1 spec) or<content>
(v0 spec), iterate through the associated light DOM nodes and append their text contentRegarding the first point, we ignore the light DOM (the element's childnodes) and skip straight to the shadow root because any light children will only be rendered if there is a related slot/content (either a default or a named one). So any which do get slotted/distributed will be picked up further down when their insertion point is processed.
If I need to add this somewhere else or did my tests wrong, do let me know.
X
in the preceding checkbox, I verify that I have signed the Contributor License Agreement