Skip to content

Commit b14f6ac

Browse files
authored
Add a way to limit which stylesheets are processed
Implements LeaVerou#6137. Adds limit property which is boolean and reflects the existence of a data-prefix attribute on the script tag. If it is there, it affects the <link> styles. Only those with a data-prefix attribute are processed.
1 parent 1a10246 commit b14f6ac

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

prefixfree.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ if(!window.addEventListener) {
1111
}
1212

1313
var self = window.StyleFix = {
14+
limit: document.currentScript.hasAttribute("data-prefix"),
15+
1416
link: function(link) {
1517
var url = link.href || link.getAttribute('data-href');
1618
try {
1719
// Ignore stylesheets with data-noprefix attribute as well as alternate stylesheets or without (data-)href attribute
18-
if(!url || link.rel !== 'stylesheet' || link.hasAttribute('data-noprefix')) {
20+
if(!url || link.rel !== 'stylesheet' || link.hasAttribute('data-noprefix')
21+
|| (self.limit && !link.hasAttribute('data-prefix')) ) {
1922
return;
2023
}
2124
}

0 commit comments

Comments
 (0)