Primary eng email
Summary
Currently stylesheets in HTML Imports (via either inline <style> or external <link rel="stylesheet">)
is applied to their master document. Deprecate and eventually remove this behavior.
Eventually we can remove the chapter 9 of HTML imports spec.
Current plan is to start showing deprecation message in 61 and remove in 65 (Mar. 2018).
Note: stylesheets defined within <template> element, which is often used for stamping
Shadow DOM contents, are not affected, as they are never applied to anything until they are
stamped.
Spec
The whole section of style in HTML Imports spec will be removed:
> The contents of the style elements and the external resources of the link elements in import
> must be considered as input sources of the style processing model [CSS2] of the master
> document.
A reference PR for removing this section:
https://github.com/w3c/webcomponents/pull/642
Motivation
Applying style from stylesheets in HTML (via <script> or <link rel="stylesheet">) has made
Blink's style engine complex, and been confusing to web developers as they are unexpectedly
applied to the master document, while none of the DOM tree inside HTML Imports is rendered.
This was originally introduced for giving "default style" for something in modular way, such
as theming using HTML imports. But as /deep/ and ::shadow combinators of Shadow DOM v0
are deprecated and they are not even available in Shadow DOM v1, the value of this feature
has become smaller.
Removing this will reduce the complexity which historically caused difficulty in making
changes in style system (e.g. see crbug.com/567021 or crbug.com/717506).
We will eventually be deprecating HTML imports as a whole once a concrete successor
gets consensus; Deprecating the style application part is a stepping stone for it.
Interoperability and Compatibility Risk
HTML Imports has been available only for Blink, and the stylesheet usage in imports
is 0.044% (source) within the whole HTML Imports usage (0.411%, source), so
currently 10+% of HTML import contains one or more stylesheets, although we do not
have concrete data about how much of them are actually styling the master document.
As no other browsers than Chrome and Opera shipped HTML Imports,
compatibility risk is only within Blink implementation and its users.
Alternative implementation suggestion for web developers
Working around the issue is as easy as hoisting the stylesheet declaration to the
master document manually or by script. For example, in an import, it is as simple
as putting the following script in an import:
<script>
var importDoc = document.currentScript.ownerDocument;
var style = importDoc.querySelector('style'); // assuming only one <style>
document.head.appendChild(style);
</script>
See https://github.com/TakayoshiKochi/deprecate-style-in-html-imports for more
concrete examples.
For Polymer (both 1.x and 2.x) users, custom-style usage is affected by this.
The framework will be updated to handle this accordingly.
Follow https://github.com/Polymer/polymer/issues/4679 for the details.
Usage information from UseCounter
https://www.chromestatus.com/metrics/feature/timeline/popularity/940
OWP launch tracking bug
and file a new bug for OWP launch tracking for removal.
Entry on the feature dashboard
https://www.chromestatus.com/features/5144752345317376
Requesting approval to remove too?
No at this point. The deprecation message, starting in 61, will include
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CADP2%3DhoP4XVmWRxTywE8aSXxVOZ_Y48Mz99J8SZK6RYhmm233A%40mail.gmail.com.
Is this the first step of deprecating and removing HTML imports entirely?
If so, you better make that clear somewhere (not in a console warning, obviously, because the usage is too high, but in a Google Developers Updates article with an alternative way of achieving the HTML import functionality, for example).
What a confusing alternative implementation (document.currentScript.ownerDocument). :( I thought document and ownerDocument are supposed to be the same in this kind of statement.
I am convinced this is a mistake. We built a complete game development IDE in a browser involving 250,000 lines of hand-written JS code, and HTML imports are by far the most important web component for this kind of development. There are a wide range of reasons for this, so I just wrote a blog post trying to comprehensively cover it all:In particular I must say that even if you want to remove HTML imports, the approach of removing styling first is a particularly inept way to go about it, for several reasons:1. Styling from imports is a useful feature, as described in my blog post.2. AFAIK Chrome's own policy for deprecation suggests features should have around 0.03% usage before being deprecated; usage is significantly (50%) higher than that according to your own data.3. You are trying to roll back this feature before providing a compelling alternative, or even a proposal for an alternative.4. You will break apps already using HTML imports - including our own. We depend on styling from HTML imports for our PWA to work correctly. We have polyfilled the feature, but because you are leaving HTML imports supported but breaking them, our polyfill will not kick in. It would be better to entirely remove them in one go than make a major breaking change, but you shouldn't do that before you even have a clear idea what comes next. There does not appear to be any convenient way to feature-detect this change. So this is pretty much the worst way you can go about deprecating a feature.
I implore you to entirely reconsider your approach.Ashley GullenScirra Ltd
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CADP2%3DhoP4XVmWRxTywE8aSXxVOZ_Y48Mz99J8SZK6RYhmm233A%40mail.gmail.com.
3. You are trying to roll back this feature before providing a compelling alternative, or even a proposal for an alternative.
We recently tried to switch our PWA to a polyfill but we ran in to a Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=733682Please don't change HTML imports until we can figure out what's going on there - otherwise we will have no options left!
<template>
<img>
<div></div>
<!-- some other element content -->
</template>
<script src="some-element.js"></script>
<script src="shim.js"></script>
<link href="some-element.css">
<link href="global.css">
<link href="mobile.css">
<html>
<head>
<link rel="import" href="some-element.html>
</head>
<body>
<some-element></some-element>
</body>
</html>
--
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CADP2%3DhoP4XVmWRxTywE8aSXxVOZ_Y48Mz99J8SZK6RYhmm233A%40mail.gmail.com.
--Takayoshi Kochi
We have polyfilled the feature, but because you are leaving HTML imports supported but breaking them, our polyfill will not kick in. It would be better to entirely remove them in one go than make a major breaking change, but you shouldn't do that before you even have a clear idea what comes next. There does not appear to be any convenient way to feature-detect this change.
--
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CADP2%3DhoP4XVmWRxTywE8aSXxVOZ_Y48Mz99J8SZK6RYhmm233A%40mail.gmail.com.
--Takayoshi Kochi