From 4dc4fd8c1db93d4dbf97d3a185ae93d8175151c9 Mon Sep 17 00:00:00 2001 From: Joy Reynolds Date: Fri, 7 Dec 2018 11:25:55 -0600 Subject: [PATCH] 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 styles. Only those with a data-prefix attribute are processed. --- prefixfree.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prefixfree.js b/prefixfree.js index e9b54e4..2e5685f 100755 --- a/prefixfree.js +++ b/prefixfree.js @@ -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; } }