Bug 11321

Summary: Element with :target pseudo-class still matched after fragment identifier change
Product: WebKit Reporter: Brad Fults <bfults>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
URL: http://xkr.us/bugs/webkit-06-003.html
Attachments:
Description Flags
Testcase
none
first attempt
mjs: review-
This timewith testcase
none
Now with improved testcase mjs: review+

Description Brad Fults 2006-10-16 15:03:27 PDT
Open the given URL (or see attachment), follow the steps.

Summary:

An element styled with the :target pseudo-class will still be matched after the fragment identifier changes.

Expected:

Elements styled with the :target pseudo-class should only be matched when the fragment identifier matches the id of the element.
Comment 1 Brad Fults 2006-10-16 15:03:54 PDT
Created attachment 11120 [details]
Testcase
Comment 2 Brad Fults 2006-10-16 15:04:13 PDT
*** This bug has been confirmed by popular vote. ***
Comment 3 Rob Buis 2006-10-24 12:03:47 PDT
Created attachment 11192 [details]
first attempt

This patch fixes the problem. Please let me know whether it is the right approach and how
to do testcase(s).
Cheers,

Rob.
Comment 4 Maciej Stachowiak 2006-10-31 04:31:35 PST
Comment on attachment 11192 [details]
first attempt

The fix looks ok to me, however, it needs a test case. To make a test case for this, you will probably have to make a page that navigates to a #fragment via window.location, forces a layout to make the :target pseudo match (for example by asking for a clientHeight property), then navigates to no fragment at all. Please resubmit with test case. The code change looks fine however.
Comment 5 Rob Buis 2006-11-17 14:35:00 PST
Created attachment 11557 [details]
This timewith testcase

This is a testcase for the bug. Unfortunately the .txt is not what I expected, whereas the .png is
correct. I'd appreciate it if anybody has suggestions for the .txt problem.
Cheers,

Rob.
Comment 6 Rob Buis 2006-11-18 06:31:41 PST
Created attachment 11566 [details]
Now with improved testcase

This testcase is much better (thnx to Mitz) since it really reflects that the bgcolor is removed when the target pseudo-class does not match anymore.
Cheers,

Rob.
Comment 7 Brad Fults 2006-11-18 13:50:05 PST
FWIW you should probably use location.hash = "#target-01"; in target-fragment-match.html.
Comment 8 Maciej Stachowiak 2006-11-18 14:48:29 PST
Comment on attachment 11566 [details]
Now with improved testcase

r=me
Comment 9 Rob Buis 2006-11-19 04:01:38 PST
Landed in r17848.