Bug 47166

Summary: querySelectorAll('body>:last-child') does not work unless HTML file ends with 'new-line'.
Product: WebKit Reporter: Hayato Ito <hayato>
Component: DOMAssignee: Adam Barth <abarth>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ap, eric, hamaji
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
test1.html
none
test2.html
none
Patch eric: review+, eric: commit-queue-

Hayato Ito
Reported 2010-10-05 03:29:48 PDT
Created attachment 69768 [details] test1.html Please see attachment files, test1.html and test2.html. The only difference between them is whether there is a 'new-line' at the end of file or not. - test1.html ends with 'new-line', like '... </html>\n<EOF>' - test2.html does not end with 'new-line', like '.... </html><EOF>'. Open each files, then try the following JavaScript code in JavaScript console. > document.querySelectorAll('body>:last-child') The results differs in test1.html and test2.html: - In test1.html, querySelectorAll returns a correct result, ['<div id="last">last</div>]. - In test2.html, querySelectorAll returns an empty list, [], which is wrong result. This might be a regression because Safari Version 5.0 (6533.16) returns the same correct results for both test1.html and test2.html.
Attachments
test1.html (208 bytes, text/html)
2010-10-05 03:29 PDT, Hayato Ito
no flags
test2.html (207 bytes, text/html)
2010-10-05 03:30 PDT, Hayato Ito
no flags
Patch (4.05 KB, patch)
2010-10-27 23:03 PDT, Adam Barth
eric: review+
eric: commit-queue-
Hayato Ito
Comment 1 2010-10-05 03:30:27 PDT
Created attachment 69769 [details] test2.html
Adam Barth
Comment 2 2010-10-05 12:59:44 PDT
We had trouble with the last-child selector early on when developing the new tree builder. There's some API we need to call on an element when it's received its last child (as I recall). I'll possible we're screwing that up in this case. The newline at the end of the file gets moved to just inside the body element, which might be confusing something. Thanks for the report. I'll take a look.
Adam Barth
Comment 3 2010-10-27 22:32:42 PDT
Looking now.
Adam Barth
Comment 4 2010-10-27 23:03:52 PDT
Eric Seidel (no email)
Comment 5 2010-10-28 13:41:31 PDT
Comment on attachment 72148 [details] Patch OK. Your test case is really subtle. It should document that it's important to not have a newline at the end. Would probably be clearer if you document.wrote the contnet into an ifram.
Eric Seidel (no email)
Comment 6 2010-10-28 13:41:49 PDT
You mentioned there was a spec bug? What's the bug?
Adam Barth
Comment 7 2010-10-28 14:00:59 PDT
(In reply to comment #6) > You mentioned there was a spec bug? What's the bug? It's for one of the FIXME cases. It's just a typo in the spec.
Adam Barth
Comment 8 2010-11-02 12:15:49 PDT
Note You need to log in before you can comment on or make changes to this bug.