Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 4dc4fd8

Browse files
joyouslyLeaVerou
authored andcommitted
Add a way to limit which stylesheets are processed (#6139)
Implements #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 4dc4fd8

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+
optIn: 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.optIn && !link.hasAttribute('data-prefix')) ) {
1922
return;
2023
}
2124
}

0 commit comments

Comments
 (0)