-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Style leaks on lazy loading or lazyRegister #3665
Comments
This is a mis-feature of HTML Imports to apply |
@azakus Thanks for replying. I found many custom elements whose styles are not wrapped in By the way, this issue did not occur on shadowDOM. I think that is because document styles which are inserted do not penetrate into custom elements there. |
Summarizing the facts I found, In case <dom-module id="x-foo">
<template>
<style>
.message:after {
content: ' style leak';
color: red;
}
</style>
</template>
<script>
Polymer({
is: 'x-foo'
});
</script>
</dom-module> In case <dom-module id="x-bar">
<style>
.message:after {
content: ' style leak';
color: red;
}
</style>
<!-- without template -->
<script>
Polymer({
is: 'x-bar'
});
</script>
</dom-module> In case <dom-module id="x-baz">
<style>
.message:after {
content: ' style leak';
color: red;
}
</style>
<template></template>
<script>
Polymer({
is: 'x-baz'
});
</script>
</dom-module> Many elements of this kind exist in iron-elements and paper-elements. So I think we should rewrite them as x-foo pattern, If this is a platform issue and there is no way to do in polymer. |
Possible style leaks in PolymerElements.
|
@naoak Thank you for all the PR's! Yes moving the Early in Polymer 1.0 we had support for It's for this reason (among others) that we now recommend
Awesome that you took the time to fix up elements that are lagging behind the recommended practice. |
@kevinpschaaf Thank you for the detailed explanation! I've seen the note before, nevertheless I was stupidly taking it as a kind of coding style. Now I've fully understood. Thanks! |
Closed based on explanation. |
Having the CSS outside of the template makes polymer/webcomponents? insert the style without any scoping into the final document, which can cause style leakage. Polymer 1.x deprecated this already: > Prior to Polymer 1.1, the recommendation was to place <style> tags inside the <dom-module> for an element (but outside the <template>). This is still supported, but is no longer recommended. (https://www.polymer-project.org/1.0/docs/devguide/styling) Polymer 2.0 will no longer support this according to https://www.polymer-project.org/2.0/docs/upgrade#dom-template. See also: Polymer/polymer#3665 See also: googlearchive/polylint#132
Description
Custom element style which is defined outside of template is leaked into other elements while its module is being dynamically loaded. This fact sometimes invokes undesired FOUC.
Live Demo
http://plnkr.co/edit/kK4ex3OkNjeCuiKUDYcG?p=preview
Steps to Reproduce
style-out-template
linkReload
buttonExpected Results
Nothing happens.
Actual Results
This is Home
background color sometimes turns yellow.Browsers Affected
Versions
The text was updated successfully, but these errors were encountered: