[英]Polymer `<custom-style>`: which line of code stops appending to DOM multiple imports of the same custom-style template module?
我的项目的上游Web组件主题是作为<custom-style>
元素链接实现的
我想将我的文档级覆盖实现为JS模块(如同,避免硬编码到app index.html
或等效内容),表面看起来很简单:
import '@vaadin/vaadin-lumo-styles/color.js';
const $template = document.createElement('template');
$template.innerHTML = `
<custom-style>
<style>
html,
:host {
--lumo-primary-color: red;
}
</style>
</custom-style>`;
document.head.appendChild($template.content);
题
文档中使用的一些Web组件也通过import '@vaadin/vaadin-lumo-styles/color.js'
导入原始主题。
我希望我的覆盖总是最后级联(没有!important
黑客)。
多个后来import '@vaadin/vaadin-lumo-styles/color.js';
调用有可能还原我的CSS自定义属性覆盖级联?
认为:
--lumo-primary-color: hsl(214, 90%, 52%);
--lumo-primary-color: red;
--lumo-primary-color: hsl(214, 90%, 52%);
)? ES6在多个位置导入文件,为什么文件加载一次? 似乎暗示也许不是,但我正在努力寻找任何明确说明<custom-style>
方式的文档。
也许https://github.com/Polymer/polymer/blob/v3.2.0/lib/elements/custom-style.js#L80是关键?
毛刺
https://glitch.com/edit/#!/roan-pizza?path=src/index.js似乎确认重复导入似乎不会导致问题,但为什么呢? 它纯粹是由于ES6模块加载缓存,还是还有其他东西呢?
浏览器检查器中的EDIT拖放<custom-style>
元素肯定会对级联产生影响(颜色根据标记顺序而变化),因此至少确认加载顺序很重要。
提示:全部删除以进行编辑。
<custom-style>
)by #id
=> <custom-style id="id01">
。 <custom-style>
> save(#id)
到edit => save(#id)
。 --lumo-primary-color
”中)是变量=> var color = red
。 <custom-style id="id01">
=> remove_all(#id)
所有内容。 我只希望你能解决你的问题。 你比我好,所以我不会写代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.