Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #33701
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Disabled stylesheet still used |
| Date | 2017-08-07 22:30 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <4023794.cEBGB3zze1@PointedEars.de> (permalink) |
| References | <kZ6dnVj08fqglhXEnZ2dnUU7-X3NnZ2d@westnet.com.au> <916b1ac8-cc6b-460f-84f1-99a0b482a053@googlegroups.com> <Ir6dncB58cHaqRXEnZ2dnUU7-WvNnZ2d@westnet.com.au> |
Andrew Poulos wrote:
> On 7/08/2017 7:10 PM, Julio Di Egidio wrote:
>> On Monday, August 7, 2017 at 8:40:13 AM UTC+2, Andrew Poulos wrote:
>>> In a page head there are references to a number of stylesheets
>>>
>>> <link id="black" type="text/css" rel="stylesheet" disabled
>>> href="black.css"> <link id="blue" type="text/css" rel="stylesheet"
>>> disabled href="blue.css"> <link id="green" type="text/css"
>>> rel="stylesheet" disabled href="_green.css">
>>> ...
>>>
>>> The js, which is called after the stylesheet references, in the page
>>> enables one of the stylesheets, eg
>>>
>>> document.getElementById("black").disabled = false;
>>
>> Try this:
>>
>> document.getElementById("black").removeAttribute("disabled");
>>
>> If not even that works, you'll have to think of another approach.
>
> The problem is that the "disabled" attribute doesn't appear to be
> honoured by Firefox so changing/removing its value will have no effect.
The `disabled` property works for me regardless whether the `disabled`
attribute is present.
(As “JJ” has pointed out _correctly_,) if you run this code through the W3C
(Nu) Validator – *always* validate your markup before posting –, you will
find that the LINK element has no `disabled` *markup* attribute in HTML 4.01
(not even Transitional), and “currently” the `link` element has no disabled
*markup* attribute in HTML 5.x or WHATWG HTML.
However, the `HTMLLinkElement` DOM interface of HTML5(.0) has a `disabled`
*interface* attribute that is implemented as a `disabled` *property* on
`link` element objects:
<https://www.w3.org/TR/2014/REC-html5-20141028/document-metadata.html#the-link-element>
Curiously, WHATWG HTML of 2017-08-04 does not even specify the `disabled`
interface attribute on the `HTMLLinkElement` interface (neither does the
`LinkStyle` interface there):
<https://html.spec.whatwg.org/multipage/semantics.html#the-link-element>
This is reflected by HTML 5.1 also not specifying that attribute anymore:
<https://www.w3.org/TR/2016/REC-html51-20161101/document-metadata.html#the-link-element>
Given that, (IIRC) your reported interpretation of the `disabled` attribute
by Blink (Chrome, Brave), Trident (IE), EdgeHTML (Edge), and WebCore (Mobile
Safari on iPhone and iPad) as setting the `disabled` property of the element
object to `true`, must be considered proprietary behavior.
Because of the references in HTML 5.x and WHATWG HTML, one must assume that
the `disabled` property of `link` element objects is now implemented only
according to the `StyleSheet` interface of the CSS Object Model (CSSOM)
Specification, which is still a Working/Editor’s Draft:
<https://www.w3.org/TR/2016/WD-cssom-1-20160317/#the-stylesheet-interface>
<https://drafts.csswg.org/cssom/#the-stylesheet-interface> (2017-08-07)
>>> On Chrome, IE, Edge and Brave (and on an iPad) the enabled stylesheet is
>>> the one that is applied.
>>>
>>> With Firefox the "last" stylesheet is always applied irrespective of
>>> which stylesheet is enabled. How can I get Firefox to only apply the
>>> enabled stylesheet?
You could insert the `link` elements disabled with scripting except one,
then enable only the target one. You could also leave the `link` elements
as they are, trusting that it will not look too bad if they are all applied,
and the disable and enable them later. Either approach could lead to FOUC,
but I cannot think of better alternatives.
>>> This implies that what I'm doing should work
>>> <https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet/disabled>
>>
>> Yes, it should, but support for these "fringe" features is not
>> guaranteed.
This is not a “‘fringe’ feature”. The property must have been supported for
several years now, considering that I have been using the Web Developer
extension, which provides a UI to do that, for that long. (Currently there
is no information about it on <http://caniuse.com/>.)
> Ok, thanks. It looks like I'll need to look at doing something like
> dynamically adding the required stylesheet instead.
Or not listen to wannabes.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Disabled stylesheet still used Andrew Poulos <ap_prog@hotmail.com> - 2017-08-07 16:39 +1000
Re: Disabled stylesheet still used Silvio <silvio@internet.com> - 2017-08-07 09:11 +0200
Re: Disabled stylesheet still used Julio Di Egidio <julio@diegidio.name> - 2017-08-07 02:10 -0700
Re: Disabled stylesheet still used Andrew Poulos <ap_prog@hotmail.com> - 2017-08-07 19:35 +1000
Re: Disabled stylesheet still used Julio Di Egidio <julio@diegidio.name> - 2017-08-07 03:41 -0700
Re: Disabled stylesheet still used Julio Di Egidio <julio@diegidio.name> - 2017-08-07 20:42 -0700
Re: Disabled stylesheet still used Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-07 22:30 +0200
Re: Disabled stylesheet still used Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-07 22:53 +0200
Re: Disabled stylesheet still used Andrew Poulos <ap_prog@hotmail.com> - 2017-08-08 12:31 +1000
Re: Disabled stylesheet still used Julio Di Egidio <julio@diegidio.name> - 2017-08-07 20:48 -0700
Re: Disabled stylesheet still used James Kirk <noneya.invalid@gmail.com> - 2017-08-07 14:43 -0400
Re: Disabled stylesheet still used James Kirk <noneya.invalid@gmail.com> - 2017-08-07 19:50 -0400
Re: Disabled stylesheet still used Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-08 06:40 +0200
OT standard whining from PointedEars nothing useful here James Kirk <noneya.invalid@gmail.com> - 2017-08-08 05:43 -0400
Re: Disabled stylesheet still used (was: OT standard whining from **** nothing useful here) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-08 13:03 +0200
Re: Disabled stylesheet still used JJ <jj4public@vfemail.net> - 2017-08-08 01:55 +0700
Re: Disabled stylesheet still used JJ <jj4public@vfemail.net> - 2017-08-08 01:58 +0700
Re: Disabled stylesheet still used Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-07 22:32 +0200
Re: Disabled stylesheet still used Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-07 21:37 +0200
Re: Disabled stylesheet still used Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-07 22:31 +0200
csiph-web