Bug Tracker

Opened 10 years ago

Closed 10 years ago

#14135 closed bug (patchwelcome)

:target selector does not work with .ready in Chrome

Reported by: [email protected] Owned by:
Priority: low Milestone: None
Component: selector Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Description

Create following HTML file. Open it in Chrome and any other browser and append hashtag #foo to the file name

Result: In Chrome, text will be blue (no class appended to #foo)

In other browsers it will be red (#foo has class bar)

	<style>
		.bar {
			color: red !important;
		}
		
		:target {
			color: blue;
		}
	</style>
	
	<div id="foo">Hello, world</div>
	
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
	<script>
		$(function() {
			$(":target").addClass("bar");
		});
	</script>

When executed from console, $(":target").addClass("bar") works

Change History (5)

comment:1 Changed 10 years ago by Rick Waldron

#14136 is a duplicate of this ticket.

comment:2 Changed 10 years ago by [email protected]

Looks like in Chrome only it will work with $(window).load, but not with $(document).ready

comment:3 Changed 10 years ago by dmethvin

Seems like this is a cantfix limitation unless someone has some ideas for fixing it.

Perhaps a related or duplicate of the bug here: https://code.google.com/p/chromium/issues/detail?id=89165

comment:5 Changed 10 years ago by timmywil

Component: unfiledselector
Priority: undecidedlow
Resolution: patchwelcome
Status: newclosed

We could defer to Sizzle in Chrome, but we'd need a support test, and I'd be suspicious of a support test involving urls. I'd welcome a patch that could implement a feature test that didn't conflict with page scrolling, pushState history, etc.

Note: See TracTickets for help on using tickets.