Summary: | ShadowRoot.getElementById() returns removed node. | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Kent Tamura <tkent> | ||||||
Component: | DOM | Assignee: | Hajime Morrita <morrita> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | cmarcelo, dglazkov, dominicc, morrita, rniwa, rolandsteiner, webkit.review.bot | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | All | ||||||||
OS: | All | ||||||||
Bug Depends on: | |||||||||
Bug Blocks: | 59832 | ||||||||
Attachments: |
|
Description
Kent Tamura
2011-06-06 22:07:50 PDT
I'm sorry for the lack of response on this issue. Another possible idea is to have insertedIntoScope() in addition or instead of insertedIntoTree(). As we pulled some functionality up from Document to TreeScope, associated part on Element and Node is also need to be generalized. I added a comment at https://bugs.webkit.org/show_bug.cgi?id=62116#c14 In Summary: If an element has an ID it just unconditionally calls treeScope()->registerID() from insertedIntoTree(), and treeScope()->unregisterID() from willRemove(). Nodes that are not in the Document are inserted into a new TreeScope-derived class DocumentAssociated, of which there is exactly 1 instance per Document, owned by the Document. DocumentAssociated::registerID()/unregisterID() are no-ops. With this, we can also get rid of all the instances where inDocument() is queried. (In reply to comment #3) > In Summary: > > If an element has an ID it just unconditionally calls treeScope()->registerID() from insertedIntoTree(), and treeScope()->unregisterID() from willRemove(). > > Nodes that are not in the Document are inserted into a new TreeScope-derived class DocumentAssociated, of which there is exactly 1 instance per Document, owned by the Document. I remember you talking about this a while back. It seems like a pretty cool idea. What are the compatibility implications? Any observable changes in behavior - especially if we introduce treeScope() accessor on an Element as public API? > > DocumentAssociated::registerID()/unregisterID() are no-ops. > > With this, we can also get rid of all the instances where inDocument() is queried. (In reply to comment #4) > I remember you talking about this a while back. It seems like a pretty cool idea. What are the compatibility implications? Any observable changes in behavior - especially if we introduce treeScope() accessor on an Element as public API? I guess it'll have the same implications as the shadow root if we allow it to be reached from JS (by accessing it directly via treeScope, or by climbing the parent pointers) - i.e., mainly what is the node type and IDL of this DocumentAssociated node? Actually, we might be able to just use a DocumentFragment for this if likewise we extend DocumentFragment to also be a TreeScope. Now TreeScope is landed. We need to test the scope is working as intended. Created attachment 128431 [details] Test Turns out, removing elements from a shadow DOM doesn't properly update the ID cache. See attached test file (using removeChild) and also the test bug 78473 attachment 127944 [details] (using innerHTML). Created attachment 144505 [details]
Patch
Hi Ryosuke, Dimitri, could you take a look? It's a simple bug fix. Comment on attachment 144505 [details] Patch Clearing flags on attachment: 144505 Committed r118804: <http://trac.webkit.org/changeset/118804> All reviewed patches have been landed. Closing bug. |