Side navigation
#7480 closed bug (invalid)
Opened November 12, 2010 07:07AM UTC
Closed December 23, 2010 05:21PM UTC
Has attribute selector not working for <a> elements
Reported by: | ryan@ryanium.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.5 |
Component: | unfiled | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
It works fine for other elements like <p>.
A test case:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="application/x-javascript" src="./jquery.js"></script> <script type="application/x-javascript"> <![CDATA[ function go() { $("[text]").each( function() { $(this).text($(this).attr("text")); } ); } ]]> </script> <title></title> </head> <body onload="go();"> <a text="foo"></a> <p text="bar"></p> </body> </html>
Fails under Firefox 4.0b8pre and Epiphany 2.30.2.
Attachments (0)
Change History (3)
Changed November 12, 2010 09:46AM UTC by comment:1
Changed November 16, 2010 01:21AM UTC by comment:2
keywords: | → needsreview |
---|
Changed December 23, 2010 05:21PM UTC by comment:3
keywords: | needsreview |
---|---|
resolution: | → invalid |
status: | new → closed |
Like jitter said, HTML5 has claimed the text
attribute and several browsers already implement it. (IE6/7/8 does not though.) Whenever you're adding custom attributes, it's a good idea to prefix with something like x-
or use the data-
attribute support sanctified by HTML5.
Not sure if this is a jQuery bug.
AFAIK with HTML 5 a
text
attribute was introduced for link tags (see spec) which contains the same as the DOM 3textContent
property.If you try this test case in different browsers you might get very different results.
In many modern browsers you will get two alerts saying "link text" and "bar" instead of "foo" and "bar". In older browser you might get "foo" and "bar" when they have no HTML 5 support yet.