Comments (1)
The HTML <style>
element does not support the disabled
attribute. IE supports it, but no other browser does. This is why the ponyfill ignores the disabled
attribute on <style>
elements.
The ponyfill does support the disabled
property on the HTMLLinkElement.sheet
and HTMLStyleElement.sheet
objects. Alternatively, you can also just remove the <link>
or <style>
element from the DOM.
Parsed cssTree and pasreVars should be cached and not re-parsed
See the __cssVars
property attached to any <link>
or <style>
element with a data-cssvars="src"
attribute. You'll find the the cssTree
object and the original CSS text stored there. The CSS text is used for comparison because any change to it will require generating new CSS output (i.e., the ponyfill has to be aware of more than just variable changes). Variables are cached elsewhere and do not need to be stored on a per-node basis:
css-vars-ponyfill/src/index.js
Lines 65 to 72 in 9811bbd
You are right about the unnecessary processing here though:
css-vars-ponyfill/src/index.js
Lines 416 to 424 in 9811bbd
Instead of blindly assigning nodeCSS
to node.__cssVars.text
, the ponyfill should be checking to see if node.__cssVars.text
exists and if it matches nodeCSS
to determine if the node needs to be processed.
const nodeCSS = cssArray[i];
const hasCSSCache = Boolean(node.__cssVars && node.__cssVars.text);
const hasCSSChanged = hasCSSCache && node.__cssVars.text !== nodeCSS;
// Node data cache
node.__cssVars = node.__cssVars || {};
node.__cssVars.text = nodeCSS;
// Only process CSS if it has changed or contains a
// custom property declarations or function
if ((hasCSSCache && hasCSSChanged) || regex.cssVars.test(nodeCSS)) {
I'll have to do some testing to verify that the change is is beneficial. It's been a while since I've looked at the code.
from css-vars-ponyfill.
Related Issues (20)
- works in IE dev mode, but not prod mode HOT 2
- CSS XHR error HOT 2
- Not working IE11 in Prod Mode HOT 3
- How to switch themes without browser reload using css variables? HOT 1
- v2.4.4 no longer transpiles to pure ECMAScript 5 HOT 1
- `CSS.supports()` doesn't support in IE11, but css-vars-ponyfill insert it into build artifact. HOT 1
- Option to skip formatting CSS HOT 3
- Does this library works for dynamically added CSS? HOT 1
- Am i missing something for use in Angular 10+? HOT 1
- the page's efficiency HOT 1
- Doesn't work with styled-components createGlobalStyle HOT 3
- Can I use it in Nuxtjs? HOT 2
- run onComplete callback too slow HOT 8
- HasVarChange has a calculation problem HOT 1
- `fixKeyframes` throws error when using shadow DOM + legacy browsers HOT 1
- IE11 js runs too slowly. Can you use this when packaging webpacks? HOT 1
- map file HOT 1
- cssVars():: CSS parse error: missing '}' HOT 1
- ie 9 10 Use without effect HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-vars-ponyfill.