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
Created attachment 19597 [details] reduction
Confirmed.
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> ... =======================================
Created attachment 19660 [details] The patch for this bug.
Comment on attachment 19660 [details] The patch for this bug. r=me
Committed revision 31083.