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

Commit

Permalink
Add a way to limit which stylesheets are processed (#6139)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joyously authored and LeaVerou committed Dec 7, 2018
1 parent 1a10246 commit 4dc4fd8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion prefixfree.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ if(!window.addEventListener) {
}

var self = window.StyleFix = {
optIn: document.currentScript.hasAttribute("data-prefix"),

link: function(link) {
var url = link.href || link.getAttribute('data-href');
try {
// Ignore stylesheets with data-noprefix attribute as well as alternate stylesheets or without (data-)href attribute
if(!url || link.rel !== 'stylesheet' || link.hasAttribute('data-noprefix')) {
if(!url || link.rel !== 'stylesheet' || link.hasAttribute('data-noprefix')
|| (self.optIn && !link.hasAttribute('data-prefix')) ) {
return;
}
}
Expand Down

0 comments on commit 4dc4fd8

Please sign in to comment.