Opened 12 years ago
Closed 12 years ago
#7087 closed enhancement (cantfix)
allow :enabled and :disabled on <link> tags
Reported by: | ghartwig | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | selector | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
:enabled really checks !disabled and !hidden. This is fine for <input> tags but not appropriate for <link> tags, which have a disabled property but not a hidden property. The code should check the hidden property only if it exists.
Workaround is to use ":not(:disabled)" instead when trying to select style sheet <link> tags that were not disabled.
Change History (7)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Yeah, I wonder if we're asking for trouble by not defining :enabled as !:disabled (or vice-versa) and having the two be asymmetrical:
enabled: function(elem){ return elem.disabled === false && elem.type !== "hidden"; }, disabled: function(elem){ return elem.disabled === true; },
Any DOM element without a Boolean disabled
property will fail both tests. The API docs vaguely warn about this, and say "input:disabled" should be used, so we could just clarify that warning and say that these two selectors are only intended to be used with inputs:
comment:3 Changed 12 years ago by
That's why I don't understand why :disabled
isn't working in my case. <link>
tags DO appear to have a disabled
property (when examined in FireBug), so it seems reasonable that these selectors could be used.
comment:4 follow-up: 5 Changed 12 years ago by
The link
element does not have a disabled
*property*:
http://www.w3.org/TR/html401/struct/links.html#h-12.3
If you are trying to set a non-standard *attribute* on the link element via .attr()
that is not the same thing.
So how are you setting the disabled property on your link elements?
comment:5 Changed 12 years ago by
What I'm doing is running through the link tags in the DOM to see which named <link>
tags are enabled and saving that value in a cookie in order to remember the user's style sheet selection. I'm not changing the disabled
attribute myself right now. The user can change it in Firefox by using the View > Page Style menu items to set which alternate style sheet is active.
I had planned on getting the title via this, but it doesn't work right now because of the :enabled
selector:
$("link[rel~='stylesheet'][title]:enabled").eq(0).attr("title")
See http://www.alistapart.com/stories/alternate/ This page says:
There is a w3c specified DOM Level 2 attribute, “disabled,” that is set to false when a style sheet is applied to the document.
comment:6 Changed 12 years ago by
Milestone: | 1.4.3 |
---|---|
Status: | new → open |
Summary: | :enabled rejects all <link> tags regardless of whether they are disabled or not → allow :enabled and :disabled on <link> tags |
Type: | bug → enhancement |
comment:7 Changed 12 years ago by
Resolution: | → cantfix |
---|---|
Status: | open → closed |
If you're hitting problems everywhere then this is also failing in the browser's querySelectorAll engine - and I don't think that that's something that we're going to try and override and "fix".
Sorry, further research shows the work-around does not work. Apparently, both :enabled and :disabled are always false (I have no explanation for this). My testing was done on Firefox 3.6.10.
New workaround: