Summary: | anchor elements href="#" and "name" attribute cause the page to jump to the end | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | jasneet <jasneet> | ||||||
Component: | Layout and Rendering | Assignee: | Nobody <webkit-unassigned> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | jasneet, webkit, yuzhu.shen | ||||||
Priority: | P2 | Keywords: | HasReduction | ||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | All | ||||||||
OS: | All | ||||||||
Attachments: |
|
Description
jasneet
2008-03-07 16:03:32 PST
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. |