8000 <link rel="stylesheet" disabled> · Issue #3840 · whatwg/html · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<link rel="stylesheet" disabled> #3840

Closed
emilio opened this issue Jul 22, 2018 · 33 comments · Fixed by #4519
Closed

<link rel="stylesheet" disabled> #3840

emilio opened this issue Jul 22, 2018 · 33 comments · Fixed by #4519
Labels
interop Implementations are not interoperable with each other topic: style

Comments

@emilio
Copy link
Contributor
emilio commented Jul 22, 2018

Consider the following test-case:

<!doctype html>
<link rel="stylesheet" disabled href="data:text/css,html { background: green }">
<div id="log"></div>
<script>
window.onload = function() {
  log.innerHTML = document.styleSheets.length;
}
</script>

Current browser behavior is:

  • Firefox: Green background, <link> appears in document.styleSheets.
  • WebKit / Blink: White background, no element in document.styleSheets.
  • Edge: White background, <link> appears in document.styleSheets.

As far as I can tell, the specified behavior is Firefox's. But that being said, Firefox supports doing link.disabled = true and toggling the disabled flag on the stylesheet, even though it's not in the webidl.

Should the disabled attribute affect whether the sheet is enabled or not? If not, could we get that clarified?

Should disabled be in HTMLLinkElements IDL? 'disabled' in HTMLLinkElement.prototype returns true everywhere.

Should a disabled sheet appear in document.styleSheets? Blink and WebKit don't remove it if you toggle the attribute, which looks definitely like a bug to me.

I think I'd expect either Firefox's behavior (disabled attribute has no effect, disabled via the IDL tweaks the disabled flag of the sheet (effectively forwards setting and getting to the sheet), or Edge's behavior, where the disabled attribute presumably reflects sheet.disabled (though note I haven't checked this in practice, chances are that link.sheet.disabled = true doesn't affect link.hasAttribute("disabled")) and stuff like that.

cc @bzbarsky @annevk @FremyCompany @lilles @ericwilligers

@emilio
Copy link
Contributor Author
emilio commented Jul 22, 2018

I guess this changed in cc5fa75...

@emilio
Copy link
Contributor Author
emilio commented Jul 22, 2018

I think it is fine to leave this unchanged spec-wise at least until there's more compat data. https://bugs.chromium.org/p/chromium/issues/detail?id=695984 was already on file to remove the attribute from Blink.

I can try to remove the WebIDL from Firefox on Nightly or something and see if there's fallout as well.

@domenic
Copy link
Member
domenic commented Jul 22, 2018

This area was last investigated in #1081, FWIW.

@emilio emilio changed the title <link rel="stylesheet" disabled> <style disabled> <link rel="stylesheet" disabled> Jul 22, 2018
@emilio
Copy link
Contributor Author
emilio commented Jul 22, 2018

cc @foolip, do you think it'd be reasonable to remove the disabled attribute from Blink?

The use counters look somewhat high: https://www.chromestatus.com/metrics/feature/timeline/popularity/809

But Blink's behavior is clearly bogus and not something we'd want to implement, in the sense that it's not on document.styleSheets list if the attribute is initially specified in the markup, but it is if it's dynamically toggled back and forth.

Alternatively, we should decide whether disabled links appear on document.styleSheets, whether they trigger loads (they don't seem to in Blink), etc. I'm happy to do that too but it seems fairly more work.

@emilio
Copy link
Contributor Author
emilio commented Jul 22, 2018

Also it's really weird that link.disabled = true; would do something completely different from link.sheet.disabled = true...

@upsuper
Copy link
Member
upsuper commented Jul 23, 2018

I would slightly hope that we don't add it, but if Blink is unwilling to remove it and it'd be required by webcompat, I guess it's fine to add... We should probably sync this carefully with the existing disabled state in CSSOM.

@emilio
Copy link
Contributor Author
emilio commented Jul 23, 2018

I think if we spec it it may be worth to prevent it from triggering loads and appearing in document.styleSheets. At least that's the only useful thing I would expect it to be used for...

That'd be consistent with current Blink / WebKit's behavior when there's no dynamic fiddling: link.sheet == null, document.styleSheets doesn't contain it, plus it prevents the weird synchronization problem altogether.

Though I'd too prefer not having to do it as well, it'd be somewhat confusing either way.

@foolip foolip added the interop Implementations are not interoperable with each other label Jul 23, 2018
@foolip
Copy link
Member
foolip commented Jul 23, 2018

I've noticed this from time to time but never known quite what to make of it, or what the compat constraints are. In https://bugs.chromium.org/p/chromium/issues/detail?id=695984&desc=2#c13 I wrote:

Concrete next step for this issue: Investigate in more detail what these IDL attributes do in each engine. One oddity to look at is the fact that HTMLLinkElement#disabled is a reflected attribute in Blink, but HTMLStyleElement#disabled and SVGStyleElement#disabled are bare IDL attributes.

The oddity here is that reflecting the content attribute doesn't mix with forwarding to the element's sheet, and Blink is inconsistent in what it does. If the attributes are reflected, then it will be possible for them to be out of sync with the real disabled state of the sheets, unless setting link.sheet.disabled should also add/remove the disabled content attribute on the link element, which would be quite unusual. (Mentioned by @emilio above re Edge's behavior too.)

There are also more related use counters:

All of them have fairly high usage, but that doesn't say too much about the web compat constraints.

Concrete options that come to mind:

  • Let the disabled content attribute be like muted, which only takes effect when the element is created. Then let the IDL attributes just forward to, in JS terms, this.sheet.disabled.
  • Make the disabled IDL attributes reflect the content attribute. Then let the "is it disabled" computation involve both the element's content attribute and the sheet's IDL attribute.

In both cases, what to do if this.sheet is null when the content attribute is added, does it prevent loading, or does it cause the sheet to be disabled when created?

@bzbarsky
Copy link
Contributor

Should disabled be in HTMLLinkElements IDL?

Yes. Afaik sites use it, and @foolip's claim about use counters agrees. I don't understand why it was ever removed from the spec. :(

I did some quick testing, and setting .disabled in Blink on an existing HTMLLinkElement in the DOM that already has a sheet does not drop the sheet but does set the sheet's disabled.

My personal, no-hysteresis, preference is that the content attribute does nothing and the DOM attribute forwards to the underlying sheet, if any... I admit that I'm biased, since that's what Gecko implements.

One comment about the above use counter data. https://www.chromestatus.com/metrics/feature/timeline/popularity/809 includes all the sites setting .disabled, due to the reflection that Blink does, as far as I can tell. So it tells us nothing about whether people are actually using the content attribute, right? Or am I totally misreading the code?

@bzbarsky
Copy link
Contributor

I guess #1081 (comment) talks a bit about extracting signal from a combination of that use counter and the V8HTMLLinkElement_Disabled_AttributeSetter use counter...

@foolip
Copy link
Member
foolip commented Jul 24, 2018

One comment about the above use counter data. https://www.chromestatus.com/metrics/feature/timeline/popularity/809 includes all the sites setting .disabled, due to the reflection that Blink does, as far as I can tell. So it tells us nothing about whether people are actually using the content attribute, right? Or am I totally misreading the code?

No, you're right about that, when https://www.chromestatus.com/metrics/feature/timeline/popularity/811 is triggered, https://www.chromestatus.com/metrics/feature/timeline/popularity/809 will be too. They're in a very similar range, so most likely the content attribute counter is dominated by the IDL attribute being said. (It'd be consistent with the data that pages are doing both, but less plausible.)

I'll update the use counter to measure the parser case separately.

@foolip
Copy link
Member
foolip commented Jul 24, 2018

Sent https://chromium-review.googlesource.com/c/chromium/src/+/1148203, but honestly I'm not too optimistic about this alone telling us whether the content attribute is needed for real-world compat.

I did a quick httparchive search for the regexp <link[^>]{1,100} disabled and that only returned 74 matches:

page,url
http://www.hacontent.com/,http://www.aon.com/human-capital-consulting/default.jsp
http://www.waxfilm.net/,http://xxxx.re/
http://www.manufaktura.com/,http://www.manufaktura.com/
http://www.trl.org/,http://www.trl.org/
http://www.isiment.com/,http://www.isiment.com/
http://www.aon.com/,http://www.aon.com/default.jsp
http://www.skiphop.com/,http://www.skiphop.com/
http://www.skiphop.com/,http://www.skiphop.com/?callback=located&_=1517679261400
http://www.skiphop.com/,http://www.skiphop.com/home?id=skiphop&_=1517679261400&callback=located
http://www.ksepb.gov.tw/,http://www.ksepb.gov.tw/
http://www.ordistricts.nic.in/,http://www.ordistricts.nic.in/
http://www.maarefquran.org/,http://www.maarefquran.org/
http://www.mosconsv.ru/,http://www.mosconsv.ru/
http://www.otsuka-plus1.com/,http://www.otsuka-plus1.com/
http://www.apkpro.ru/,http://www.apkpro.ru/
http://www.dxbsky.com/,http://www.dxbsky.com/
http://www.supadipa.com/,http://www.supadipa.com/
http://www.learncodeonline.in/,http://www.learncodeonline.in/
http://www.clien.net/,http://www.clien.net/
http://www.funai.gov.br/,http://www.funai.gov.br/
http://www.oshkosh.com/,http://www.oshkosh.com/
http://www.nomade.kr/,http://www.nomade.kr/
http://www.rev.cn/,http://www.rev.cn/
http://www.rev.cn/,http://www.rev.cn/js/header.js
http://www.shasm.gov.cn/,http://www.shasm.gov.cn/JScript.js
http://www.xn--80aaaac8algcbgbck3fl0q.xn--p1ai/,http://www.xn--80aaaac8algcbgbck3fl0q.xn--p1ai/
http://www.scorecardrewards.com/,https://www.scorecardrewards.com/assets/hinda-0.0.1.11756.js
http://www.gate.io/,http://www.gate.io/
http://www.gate.io/,https://gate.io/
http://www.cpcb.nic.in/,http://www.cpcb.nic.in/
http://www.aon.fr/,http://www.aon.fr/france/default.jsp
http://www.dajs.gov.cn/,http://www.dajs.gov.cn/
http://www.chilicel.com/,http://www.chilicel.com/
http://www.steamspy.com/,http://www.steamspy.com/
http://www.hainanairlines.com/,http://www.hainanairlines.com/distil_identify_cookie.html?httpReferrer=%2F&uid=8FD9C2E9-ED92-3AD1-97CC-88143764D73C
http://www.myrunningman.com/,http://www.myrunningman.com/
http://www.sanwa-p.co.jp/,https://www.sanwa-p.co.jp/js/jquery.font.js
http://www.teenarea.biz/,http://www.teenarea.biz/
http://www.wlnupdates.com/,http://www.wlnupdates.com/
http://www.yourtotalrewards.com/,http://www.aon.com/human-capital-consulting/default.jsp
http://www.cbenni.com/,http://www.cbenni.com/
http://www.mphro.com/,http://www.aon.com/human-capital-consulting/default.jsp
http://www.kkesh.med.sa/,http://www.kkesh.med.sa/
http://www.connected2.me/,http://www.connected2.me/
http://www.microfocus.net/,http://www.microfocus.net/
http://www.ficpa.org/,http://www.ficpa.org/
http://www.supeera.com/,http://www.supeera.com/
http://www.pesc.ru/,http://www.pesc.ru/
http://www.synchroarts.com/,http://www.synchroarts.com/
http://www.dxbpp.gov.ae/,http://www.dxbpp.gov.ae/
http://www.vodafonefreezone.com/,http://www.vodafonefreezone.com/
http://www.tmbam.com/,https://www.tmbam.com/home/th/inc/setFont.js
http://www.jnu.ac.in/,http://www.jnu.ac.in/
http://www.bemlindia.com/,http://www.bemlindia.com/
http://www.fcijobportalmah.com/,http://fcijobportalmah.com/FCI01/js/FontSizes.js
http://www.aon.it/,http://www.aon.com/italy
http://www.mkb.hu/,http://www.mkb.hu/
http://www.carters.com/,http://www.carters.com/
http://www.szhr.com.cn/,http://www.szhr.com.cn/hrmall/index-center.html
http://www.szhr.com.cn/,http://www.szhr.com.cn/hrmall/index_ad_item_hr.html
http://www.alsok.co.jp/,http://www.alsok.co.jp/
http://www.wum.edu.pl/,http://www.wum.edu.pl/themes/frameworkNOWY/kontrast.js?V
http://www.wum.edu.pl/,http://www.wum.edu.pl/modules/styleswitcher/styleswitcher.js
http://www.cartersoshkosh.ca/,http://www.cartersoshkosh.ca/
http://www.cartersoshkosh.ca/,http://www.cartersoshkosh.ca/?callback=located&_=1517713421387
http://www.cartersoshkosh.ca/,http://www.cartersoshkosh.ca/on/demandware.store/Sites-CartersCA-Site/en_CA/Default-Start?callback=located&_=1517713421387
http://www.hewitt.com/,http://www.aon.com/human-capital-consulting/default.jsp
http://www.jeld-wen.com/,http://www.jeld-wen.com/
http://www.dotajackpots.com/,http://www.dotajackpots.com/
http://www.cvag.de/,http://www.cvag.de/
http://www.triptogether.com/,http://www.triptogether.com/
http://www.oddistricts.nic.in/,http://www.oddistricts.nic.in/
http://www.previdencia.gov.br/,http://www.previdencia.gov.br/
http://www.bjft.gov.cn/,http://www.bjft.gov.cn/top_lan.html

That's not a lot, but there is some stuff in there that looks like deliberate use. On https://www.ksepb.gov.tw/ the disabled attribute is everywhere, and then there's some scripts that poke at the IDL attributes too. Unfortunately, this page doesn't load in Firefox at all due to an invalid cert, so I can't check if it's broken or not.

Spending a couple of hours on this list and comparing the result in a Chromium build with or without the disabled content attribute supported should give a good idea about the risks.

Before I go spend a bunch of time on that I'd like to hear if the Edge or WebKit team have thoughts on this. @patrickkettner @cdumez, can you find contacts?

@foolip
Copy link
Member
foolip commented Jul 24, 2018

Looking a bit more, there's a layer between the disabled content attribute and underlying sheet which would explain the differences in document.styleSheets:
https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/html/link_style.cc?l=204&rcl=9a429d1f18c5b2713ab8bad9f795217efe0d7bcd

This dates back to 2002/2003 when Dave Hyatt exclaimed that "This disabling stuff is complicated!"
https://trac.webkit.org/changeset/2318/webkit
https://trac.webkit.org/changeset/4010/webkit

Because of the reflection, this stuff is in play when setting the disabled IDL attribute on HTMLLinkElement as well.

aarongable pushed a commit to chromium/chromium that referenced this issue Jul 25, 2018
The existing kHTMLLinkElementDisabled counter is poisoned by the
reflected IDL attribute, as pointed out by bz:
whatwg/html#3840 (comment)

Change-Id: Ic4917290475f1ad6d9baba06620a485b78edac59
Reviewed-on: https://chromium-review.googlesource.com/1148203
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Philip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577870}
@emilio
Copy link
Contributor Author
emilio commented Apr 8, 2019

Here's a concrete proposal: Make <link rel="stylesheet" disabled> work by not loading the stylesheet, and by not adding the stylesheet to document.styleSheets, instead of forwarding to the stylesheet's disabled attribute.

This is a nice way of preventing stylesheet loads, and is the sanest thing I could think of, since <style>'s disabled getters and setters do the same in every browser.

@foolip does that sound reasonable? It means that using the getter and setter produces the same result rendering-wise, and consistent results regardless of whether the attribute was set from the parser or not.

@emilio
Copy link
Contributor Author
emilio commented Apr 8, 2019

Ugh, the only reason that people use disabled is because it's the only way to enable an alternate stylesheet in Blink / WebKit... ;_;

@emilio
Copy link
Contributor Author
emilio commented Apr 8, 2019

So, ok, a bit more of an elaborated answer (I'll use WebKit and Blink interchangeably here).

We (Gecko) get compat issues from not supporting <link rel="stylesheet" disabled>. The Blink model for this is quite weird as described above.

This attribute is mostly used in along with <link rel="alternate stylesheet">, as a work-around to enable alternate stylesheets in WebKit. In WebKit you cannot enable an alternate sheet unless it's gotten explicitly disabled before. This is because WebKit doesn't model alternate stylesheets like the spec says (in terms of the disabled state), and in order to get to apply the stylesheet properly.

For example, there's no other way to get the stylesheet as follows to apply in WebKit other than changing the rel attribute or toggling link.disabled back and forth:

<link rel="alternate stylesheet" href="data:text/css,html { background: green }">
  • sheet.disabled is false, link.disabled is false
  • Setting any of those again does nothing. Setting sheet.disabled to true and then false, also does nothing.
  • Setting link.disabled = true and then link.disabled = false does make the stylesheet apply.

So for convenience, and in order to be able to toggle alternate stylesheets across browsers, people do the following:

<link rel="alternate stylesheet" href="data:text/css,html { background: green }" disabled>

So that they can enable the stylesheet using link.disabled = false, and disable it using link.disabled = true in both Gecko / Edge and WebKit.

There are a whole lot of extra issues in WebKit implementation, like the stylesheet inconsistently appearing in document.styleSheets.

Proposed model

The model I proposed above tries to get the benefits of the current disabled implementation in WebKit (avoids the stylesheet load when the attribute is present), while trying to make it saner. However as-is it would break the "enabling alternate stylesheet" case. So I propose adopting that model with a slightly different change to make it compatible with that use-case:

  • A link whose disabled attribute has been removed gets set a new flag (let's call this "explicitly enabled flag").
  • The add a CSS style sheet definition in CSSOM needs to take that flag into account, such as to not set the "disabled" flag if the "explicitly enabled flag" is set.

So with that, the proposal is:

  • The HTMLLinkElement.disabled getter and setter reflects the disabled content attribute and nothing else.
  • There's a new flag in HTMLLinkElement, the "explicitly enabled" flag, that gets set whenever the disabled attribute in the <link> element is removed, and needs to get passed down to CSSOM.
  • Link's with the disabled attribute do not load stylesheets (and thus their sheet getter returns null).
  • Stylesheets with their "explicitly enabled" flag don't get their "disabled flag" set when adding a CSS sheet.

Does that sound reasonable to everybody?

// cc @lilles @rniwa

@bzbarsky
Copy link
Contributor
bzbarsky commented Apr 8, 2019

"reasonable" is a high bar, but if WebKit/Blink are not going to fix their bugs around alternate stylesheets this sounds like the next-best option to me...

@emilio
Copy link
Contributor Author
emilio commented Apr 9, 2019

https://bugzilla.mozilla.org/show_bug.cgi?id=1281135 has a patch implementing that on Gecko, fwiw.

annevk added a commit that referenced this issue Apr 10, 2019
Tests: ...

Fixes #3840, maybe.
@rniwa
Copy link
rniwa commented Apr 13, 2019

I agree we should do something to improve interoperability here.

@emilio : When you say "WebKit" in #3840 (comment) you mean both WebKit and Blink? If so, changing the behavior of WebKit and Blink to match the spec might pose a compatibility risk.

In particular, removing & adding an item from document.styleSheets seems risky to me because some people might relying on finding a given stylesheet with a given index value even after disabling one.

@smfr @hober

@emilio
Copy link
Contributor Author
emilio commented Apr 13, 2019

@emilio : When you say "WebKit" in #3840 (comment) you mean both WebKit and Blink? If so, changing the behavior of WebKit and Blink to match the spec might pose a compatibility risk.

Yes.

In particular, removing & adding an item from document.styleSheets seems risky to me because some people might relying on finding a given stylesheet with a given index value even after disabling one.

Right now the WebKit / Blink behavior doesn't really make much sense. If you use <link rel="stylesheet" disabled> it doesn't appear in document.styleSheets, if you unset and set the attribute again, then it magically appears. That doesn't make sense to me.

I think it's also a bug that in WebKit / Blink you cannot enable an alternate stylesheet without the disabled attribute: <link rel="alternate stylesheet" href="foo.css"> cannot be enabled, unless you add the disabled attribute and then remove it.

I think what I propose is a good way to get interop with a somewhat consistent model. But I'm all ears if you have better ideas. Given the poor interop situation here I think we have some leeway...

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Apr 19, 2019
…reflect that attribute. r=bzbarsky

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from the setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573

--HG--
extra : moz-landing-system : lando
mykmelez pushed a commit to mykmelez/gecko that referenced this issue Apr 19, 2019
…reflect that attribute. r=bzbarsky

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from the setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573
a2sheppy added a commit to a2sheppy/browser-compat-data that referenced this issue Jun 16, 2019
At some point, the link element's disabled attribute was removed
from the spec. It has since been restored but was not linked to
the stylesheet's disabled attribute.

In whatwg/html#3840, the two are being
revised to reflect one another. This BCD update adds data to
indicate this.
queengooborg pushed a commit to mdn/browser-compat-data that referenced this issue Jul 9, 2019
* Update for link element's disabled attribute being added back
At some point, the link element's disabled attribute was removed
from the spec. It has since been restored but was not linked to
the stylesheet's disabled attribute.

In whatwg/html#3840, the two are being
revised to reflect one another. This BCD update adds data to
indicate this.

* First bit of corrections for emilio

* Further fixes

* Apply Chrome information to other browsers, with minor rewording to be
inclusive of all Blink-based products. Replaced old and incomplete note
on the Android WebView entry.
marcoscaceres pushed a commit to web-platform-tests/wpt that referenced this issue Jul 23, 2019
…ttribute.

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from the setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1281135
gecko-commit: edbf9758ea946df5063e84c397c43208c555fd74
gecko-integration-branch: central
gecko-reviewers: bzbarsky
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 4, 2019
…reflect that attribute. r=bzbarsky

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from the setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573

UltraBlame original commit: ef991fe893a435f4416bde5f518135655a9740e1
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 4, 2019
…reflect that attribute. r=bzbarsky

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from th
6D40
e setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573

UltraBlame original commit: edbf9758ea946df5063e84c397c43208c555fd74
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 4, 2019
…reflect that attribute. r=bzbarsky

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from the setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573

UltraBlame original commit: ef991fe893a435f4416bde5f518135655a9740e1
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 4, 2019
…reflect that attribute. r=bzbarsky

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from the setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573

UltraBlame original commit: edbf9758ea946df5063e84c397c43208c555fd74
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 4, 2019
…reflect that attribute. r=bzbarsky

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from the setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573

UltraBlame original commit: ef991fe893a435f4416bde5f518135655a9740e1
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 4, 2019
…reflect that attribute. r=bzbarsky

...instead of forwarding to the sheet like HTMLStyleElement does.

I've proposed this behavior in:

  whatwg/html#3840 (comment)

I think this is one of the sane behaviors we can have, what Blink / WebKit do
makes no sense to me.

Alternative potentially-sane behavior is making the initial value of the
stylesheet's disabled bit the same as the content attribute, and both reflect
and forward the attribute from the setter.

That means that setAttribute does something different than setting `disabled`,
which means that you can get into all sorts of funny states when reloading the
sheet... So I rather not do that.

Differential Revision: https://phabricator.services.mozilla.com/D26573

UltraBlame original commit: edbf9758ea946df5063e84c397c43208c555fd74
@Zibri
Copy link
Zibri commented Nov 30, 2019

also,

<style disabled="true">
...
</style>

would be really nice.

@annevk
Copy link
Member
annevk commented Apr 2, 2020

@a2sheppy apologies for the delay here, there's still a couple things to sort out, but I hope to make some progress again on this.

@Zibri that would be a new feature that's probably best filed as a new issue.

Looking at the tests, currently Chrome/Safari fail half of 001 and all of 002. Chrome also fails 007. The tests are located at css/cssom/HTMLLinkElement-disabled* in WPT. In particular Chrome/Safari don't null out ownerNode for a disabled style sheet. And Chrome does something weird around disabled attribute reflection.

@emilio https://drafts.csswg.org/cssom/#css-style-sheets doesn't currently say that owner node is supposed to be null when the style sheet is disabled.

@tkent-google do you agree 007 is a bug in Chrome?

@emilio
Copy link
Contributor Author
emilio commented Apr 2, 2020

@emilio https://drafts.csswg.org/cssom/#css-style-sheets doesn't currently say that owner node is supposed to be null when the style sheet is disabled.

Yeah but this makes a disabled link not be the same as a disabled sheet.

@tkent-google
Copy link
Contributor

@tkent-google do you agree 007 is a bug in Chrome?

I delegate to @mfreed7. I'm not responsible for HTML any longer.

@annevk
Copy link
Member
annevk commented Apr 8, 2020

@emilio there's no text for returning null when the owner is disabled either. But if that's done as part of adding the flag that's needed for #4519 I guess that's fine.

@emilio
Copy link
Contributor Author
emilio commented Apr 9, 2020

@annevk when the owner is disabled there's no stylesheet associated to the owner so there's no stylesheet to return null from anywhere.

@mfreed7
Copy link
Contributor
mfreed7 commented May 26, 2020

Sorry for the delay responding to this one. Generally, this sounds like a reasonable suggestion, and improving interop (and sanity) here sounds like a good thing. I'm a bit concerned about compat, given the longstanding weird behavior in Webkit/Blink. I understand that the interop issues might mean the compat issues aren't so bad, but probably not zero either.

Does the current Gecko behavior match #4519?

@emilio
Copy link
Contributor Author
emilio commented May 26, 2020

Yes, Gecko behavior is tested in these WPTs. As you may note, Safari and Chrome are pretty close to green in those tests.

@mfreed7
Copy link
Contributor
mfreed7 commented May 27, 2020

Thanks. I have a patch ready that implements the new behavior in Chromium, which I'll try to land soon in M85 and see if there are any reported compat bugs.

Thanks for writing the tests for this - made implementing it easy.

@domenic
Copy link
Member
domenic commented May 27, 2020

Hooraaay!

Shall we hold off on landing #4519 until Chromium gets some compat data? Or should we land it, since the current spec doesn't have <link disabled> at all, and consider if we need to change the behavior to Chromium/WebKit-style as a followup?

@lilles
Copy link
Contributor
lilles commented May 27, 2020

Yay! Thanks for doing this Mason!

@mfreed7
Copy link
Contributor

Shall we hold off on landing #4519 until Chromium gets some compat data? Or should we land it, since the current spec doesn't have <link disabled> at all, and consider if we need to change the behavior to Chromium/WebKit-style as a followup?

Either way is ok by me, but I suppose I'd prefer that it lands. As you mentioned, there's no spec and mixed implementations at the moment, so it seems better to land something and then tweak it if necessary. But clearly, it's up to you.

annevk added a commit that referenced this issue May 29, 2020
pull bot pushed a commit to Yannic/chromium that referenced this issue Jun 3, 2020
Previously, Chromium had intermittent behavior with respect to the
"disabled" attribute:
- <link id=foo rel="stylesheet" disabled> would not show up in
  document.styleSheets.
- foo.disabled=false; foo.disabled=true; would cause it to appear
  (and remain) in document.styleSheets.
- <link rel="alternate stylesheet"> cannot be enabled, except by
  disabling and re-enabling it.
- When disabled, link.ownerNode was not null

The above issues are being resolved with this CL.

See the spec discussion and PR here:
 whatwg/html#3840
 whatwg/html#4519

And the ChromeStatus and I2S here:
 https://chromestatus.com/feature/5110851973414912
 https://groups.google.com/a/chromium.org/d/msg/blink-dev/3izM5vVo98U/iDLjz_TwAgAJ=

WPT tests are located here:
 https://wpt.fyi/results/css/cssom?label=master&label=experimental&aligned&q=htmllinkelement-disabled
and they show that Firefox already implements the new behavior,
while WebKit does not. With this CL, all 7 tests are now green.

Bug: 695984, 1087043
Change-Id: Ic6d2c8e901a72885b9f4806c616adb95e019cf09
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216701
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774658}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other topic: style
Development

Successfully merging a pull request may close this issue.

0