Side navigation
#7087 closed enhancement (cantfix)
Opened September 27, 2010 10:35AM UTC
Closed April 16, 2011 10:18PM UTC
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.
Attachments (0)
Change History (7)
Changed September 27, 2010 11:18AM UTC by comment:1
Changed September 27, 2010 11:26PM UTC by comment:2
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
disabledproperty 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:
Changed September 28, 2010 10:19AM UTC by comment:3
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.
Changed September 30, 2010 03:11PM UTC by comment:4
The
linkelement 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?
Changed October 01, 2010 08:31AM UTC by comment:5
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.
Changed October 14, 2010 06:55AM UTC by comment:6
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 |
Changed April 16, 2011 10:18PM UTC by comment:7
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: