|Summary:||anchor elements href="#" and "name" attribute cause the page to jump to the end|
|Component:||Layout and Rendering||Assignee:||Nobody <webkit-unassigned>|
|Severity:||Normal||CC:||jasneet, webkit, yuzhu.shen|
|Version:||528+ (Nightly build)|
Description jasneet 2008-03-07 16:03:32 PST
I Steps: Go to the attached reduction. Click on "Click me" II Issue: Notice that on clicking "Click me", the page jumps to the end. This happens only in Safari III Conclusion: combination of href="#" and name="" is causing the issue. IV Other browsers: IE7: ok FF: ok Opera: ok V Nightly tested: 30236
Comment 2 Robert Blaut 2008-03-08 14:24:42 PST
Comment 3 Yuzhu Shen 2008-03-11 05:55:53 PDT
This issue is similar with bug 14867. Because of revision 30243, however, bug 14867 is ok now. In revision 30243, FrameLoader::gotoAnchor() is modified: DeprecatedString ref = m_URL.encodedHtmlRef(); --> String ref = m_URL.ref(); With this change, WebKit now interprets the fragment identifier of <a href="#"> as an empty string (length = 0) instead of a null string. As I commented in bug 14867, WebKit searches the anchor node in two steps: (in bool FrameLoader::gotoAnchor(const String& name)) 1) searches any node whose id attribute is the same as the fragment identifier. If the fragment identifier is an empty string, it returns directly. 2) searches in a set of <a> elements that have name attributes, using HTMLCollection::namedItem(). It should be noted that namedItem() first searches for an object with a matching id attribute. If a match is not found, the method then searches for an object with a matching name attribute. Consider the following node: <a name="">...</a> Its id attribute is not specified (returned as a null string when querying it), so it won't match. However, if we are searching with a empty string, it will match the name attribute. As a result, clicking the "Goto Top" link in the page below will bring you to the anchor "Oops!" but not the top of the page. ======================================= ... <a href="#">Goto Top</a> ... ... <a name="">Oops!</a> ... =======================================
Comment 4 Yuzhu Shen 2008-03-11 06:01:36 PDT
Created attachment 19660 [details] The patch for this bug.
Comment 5 Darin Adler 2008-03-11 07:43:56 PDT
Comment on attachment 19660 [details] The patch for this bug. r=me
Comment 6 Darin Adler 2008-03-16 13:35:47 PDT
Committed revision 31083.