WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
59461
WebKitDOMNodeList's internal order is modified when iterating it
https://bugs.webkit.org/show_bug.cgi?id=59461
Summary
WebKitDOMNodeList's internal order is modified when iterating it
Xavier Claessens
Reported
2011-04-26 08:15:35 PDT
I have an issue when trying to implement adium theme "focus" feature in Empathy[1] My code needs to list all nodes having "focus" in its classes, like <div class="foo focus bar"> and then remove focus from the list. So basically like this: dom = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view)); nodes = webkit_dom_document_get_elements_by_class_name (dom, "focus"); for (i = 0; i < webkit_dom_node_list_get_length (nodes); i++) { webkit_dom_html_element_set_class_name (element, new_class_name); } This problem with that code is that it will update only one node op 2. My guess is that when a node is modified, it gets moved to the end of the nodes list. This seems really weird behaviour... Note that adium does exactly the same code using the MacOS objective-C API of webkit and it works as expected. [1]
https://bugzilla.gnome.org/show_bug.cgi?id=443884
Attachments
Add attachment
proposed patch, testcase, etc.
Xavier Claessens
Comment 1
2011-04-26 08:20:32 PDT
oohh, actually the is a small difference in adium's code, it uses querySelectorAll. And that actually work with gtk API too, like that: nodes = webkit_dom_document_query_selector_all (dom, ".focus", NULL); This is really confusing...
Sam Weinig
Comment 2
2011-04-26 09:27:42 PDT
This is how NodeLists work in the DOM. The ones returned from getElementsByClassName are live (
http://www.whatwg.org/specs/web-apps/current-work/#dom-document-getelementsbyclassname
) (meaning they update due to DOM modifications) while the ones returned from querySelectorAll (
http://www.w3.org/TR/selectors-api/#queryselectorall
) are static.
Xavier Claessens
Comment 3
2011-04-26 10:14:08 PDT
Is that documented in the API? Feel free to close as INVALID then.
Xan Lopez
Comment 4
2011-04-26 11:38:39 PDT
As Sam suggests, we just do whatever the underlying DOM implementation does, so we should be faithful to the spec here. Closing!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug