style element & web components

style.textContent

style.setContent bug

style.textContent

    const style = document.createElement(`style`);
// this.shadowRoot.appendChild(this.templateContent);
// log(`this.shadowRoot`, this.shadowRoot); // style.setContent not exist
style.textContent = `
.run {
width: 100px;
height: 100px;
background: url(https://www.boston.com/wp-content/uploads/2016/05/yuge_anger.png) 0 0;
animation: run 500 step(6) infinite;
}
@keyframes run {
from {
background-position: 0 0;
}
to {
background-position: -600px 0;
}
}
`;
// empty style bug

test OK

  const head = document.querySelector(`head`);

  const style = document.createElement(`style`);

  style.textContent = `
.run {
width: 100px;
height: 100px;
background: url(https://www.boston.com/wp-content/uploads/2016/05/yuge_anger.png);
animation: run 500 step(6) infinite;
}
@keyframes run {
from {
background-position: 0 0;
}
to {
background-position: -600px 0;
}
}
`; head.appendChild(style);

live demo

See the Pen web components(trump component) by xgqfrms
(@xgqfrms) on CodePen.

style.textContent !== style.setContent


style.textContent style.cssText style.innerHTML style.innerText

https://youtu.be/0QLHEOVnYtY?t=3333

style element

https://developer.mozilla.org/en/docs/Web/HTML/Element/style

refs

https://codepen.io/xgqfrms/pen/ZEWXrVz?editors=1111

style.textContent

https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


style element & web components的更多相关文章

  1. how to create a style element in js (many ways)

    how to create a style element in js (many ways) create style in js Constructed StyleSheets CSSStyleS ...

  2. 在angular项目中使用web-component ----How to use Web Components with Angular

    原文: https://medium.com/@jorgecasar/how-to-use-web-components-with-angular-41412f0bced8 ------------- ...

  3. web components & publish custom element & npm

    web components & publish custom element & npm https://www.webcomponents.org/publish Polymer ...

  4. 【转】Facebook React 和 Web Components(Polymer)对比优势和劣势

    原文转自:http://segmentfault.com/blog/nightire/1190000000753400 译者前言 这是一篇来自 StackOverflow 的问答,提问的人认为 Rea ...

  5. The state of Web Components

    Web Components have been on developers’ radars for quite some time now. They were first introduced b ...

  6. Web Components

    Web Components是不是Web的未来   今天 ,Web 组件已经从本质上改变了HTML.初次接触时,它看起来像一个全新的技术.Web组件最初的目的是使开发人员拥有扩展浏览器标签的能力,可以 ...

  7. 前端应该知道的Web Components

    前端组件化的痛点 在前端组件化横行的今天,确实极大的提升了开发效率.不过有一个问题不得不被重视,拟引入的这些html.css.js代码有可能对你的其他代码造成影响. 虽然我们可以通过命名空间.闭包等一 ...

  8. 一个使用 Web Components 的音乐播放器: MelodyPlayer

    先上效果预览: Web Components 首先,什么是 Web Components ? MDN 给出的定义是: Web Components 是一套不同的技术,允许您创建可重用的定制元素(它们的 ...

  9. web Components 学习之路

    就目前而言,纯粹的Web Components在兼容性方面还有着较为长远的路,这里做个记录总结,以纪念自己最近关于Web Components的学习道路. 参考教材 JavaScript 标准参考教程 ...

随机推荐

  1. GRPC Health Checking Protocol Unavailable 14

    https://github.com/grpc/grpc/blob/master/doc/health-checking.md GRPC Health Checking Protocol Health ...

  2. (万字好文)Dubbo服务熔断与降级的深入讲解&代码实战

    原文链接:(万字好文)Dubbo服务熔断与降级的深入讲解&代码实战 一.Dubbo服务降级实战 1 mock 机制 谈到服务降级,Dubbo 本身就提供了服务降级的机制:而 Dubbo 的服务 ...

  3. 洛谷P2865

    感觉此题可作为严格次短路的模板,因此来写一写 Description 给定 \(n\) 个点,\(r\) 条双向道路,求从 \(1\) 号点到 \(n\) 号点的严格次短路 Solution 维护两个 ...

  4. cogs 2566 字符串最大值

    2566. [51nod 1129] 字符串最大值 ★★   输入文件:string_maxval.in   输出文件:string_maxval.out   简单对比时间限制:1 s   内存限制: ...

  5. REST架构及其介绍

    概述     REST是英文Representational State Transfer的缩写,中文翻译:表述性状态转移.     他是由Roy Thomas Fielding博士在他的论文 < ...

  6. linux 一分钟安装maven linux

    mkdir maven cd maven/ wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/ ...

  7. 90% 的 Java 程序员都说不上来的为何 Java 代码越执行越快(2)- TLAB预热

    经常听到 Java 性能不如 C/C++ 的言论,也经常听说 Java 程序需要预热,那么其中主要原因是啥呢? 面试的时候谈到 JVM,也有很多面试官喜欢问,为啥 Java 程序越执行越快呢? 一般人 ...

  8. Codeforces Round #626 Div2 D. Present(位掩码,二分)

    题目链接:https://codeforces.com/contest/1323/problem/D 题意:给了大小为4e5的数组a,其中1<=ai<=1e7.求所有点对和的异或和,即: ...

  9. BZOJ-1086 [SCOI2005]王室联邦 (树分块)

    递归处理子树,把当前结点当作栈底,然后递归,回溯回来之后如果栈中结点数量到达某一个标准时,弹出栈中所有的元素分到一个块中,最后递归结束了如果栈中还有元素,那么剩下的这些元素放在新的块中 题目:BZOJ ...

  10. 【noi 2.6_9265】取数游戏(DP)

    题意:从自然数1到N中不取相邻2数地取走任意个数,问方案数. 解法:f[i][1]表示在前i个数中选了第i个的方案数,f[i][0]表示没有选第i个.f[i][1]=f[i-1][0];  f[i][ ...