@emotion/sheet
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -46,74 +46,71 @@ 'use strict'; | ||
function _StyleSheet(options) { | ||
if (options === undefined) options = {}; | ||
this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy; // maxLength is how many rules we have per style tag, it's 65000 in speedy mode | ||
// because that's the upper limit in IE 10 TODO: make sure that is actually correct | ||
// it's 1 in dev because we insert source maps that map a single rule to a location | ||
// and you can only have one source map per style tag | ||
var StyleSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
function StyleSheet(options) { | ||
if (options === undefined) options = {}; | ||
this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy; // maxLength is how many rules we have per style tag, it's 65000 in speedy mode | ||
// because that's the upper limit in IE 10 TODO: make sure that is actually correct | ||
// it's 1 in dev because we insert source maps that map a single rule to a location | ||
// and you can only have one source map per style tag | ||
this.maxLength = options.maxLength || this.isSpeedy ? 65000 : 1; | ||
this.tags = []; | ||
this.ctr = 0; | ||
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets | ||
this.maxLength = options.maxLength || this.isSpeedy ? 65000 : 1; | ||
this.tags = []; | ||
this.ctr = 0; | ||
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets | ||
this.key = options.key || ''; // $FlowFixMe | ||
this.key = options.key || ''; | ||
this.container = options.container || ( // $FlowFixMe | ||
typeof document !== 'undefined' ? document.head : null); | ||
} | ||
this.container = options.container || (typeof document !== 'undefined' ? document.head : null); | ||
} | ||
var _proto = StyleSheet.prototype; | ||
function _insert(rule) { | ||
if (this.ctr % this.maxLength === 0) { | ||
var _tag = document.createElement('style'); | ||
_proto.insert = function insert(rule) { | ||
if (this.ctr % this.maxLength === 0) { | ||
var _tag = document.createElement('style'); | ||
_tag.setAttribute('data-emotion', this.key); | ||
_tag.setAttribute('data-emotion', this.key); | ||
if (this.nonce !== undefined) { | ||
_tag.setAttribute('nonce', this.nonce); | ||
} | ||
if (this.nonce !== undefined) { | ||
_tag.setAttribute('nonce', this.nonce); | ||
} | ||
_tag.appendChild(document.createTextNode('')); | ||
_tag.appendChild(document.createTextNode('')); | ||
this.container.appendChild(_tag); | ||
this.tags.push(_tag); | ||
} | ||
this.container.appendChild(_tag); | ||
this.tags.push(_tag); | ||
} | ||
var tag = this.tags[this.tags.length - 1]; | ||
var tag = this.tags[this.tags.length - 1]; | ||
if (this.isSpeedy) { | ||
var sheet = sheetForTag(tag); | ||
if (this.isSpeedy) { | ||
var sheet = sheetForTag(tag); | ||
try { | ||
// this is the ultrafast version, works across browsers | ||
// the big drawback is that the css won't be editable in devtools | ||
sheet.insertRule(rule, sheet.cssRules.length); | ||
} catch (e) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn("There was a problem inserting the following rule: \"" + rule + "\"", e); | ||
try { | ||
// this is the ultrafast version, works across browsers | ||
// the big drawback is that the css won't be editable in devtools | ||
sheet.insertRule(rule, sheet.cssRules.length); | ||
} catch (e) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn("There was a problem inserting the following rule: \"" + rule + "\"", e); | ||
} | ||
} | ||
} else { | ||
tag.appendChild(document.createTextNode(rule)); | ||
} | ||
} else { | ||
tag.appendChild(document.createTextNode(rule)); | ||
} | ||
this.ctr++; | ||
} | ||
this.ctr++; | ||
}; | ||
function _ref(tag) { | ||
return tag.parentNode.removeChild(tag); | ||
} | ||
_proto.flush = function flush() { | ||
// $FlowFixMe | ||
this.tags.forEach(function (tag) { | ||
return tag.parentNode.removeChild(tag); | ||
}); | ||
this.tags = []; | ||
this.ctr = 0; | ||
}; | ||
function _flush() { | ||
// $FlowFixMe | ||
this.tags.forEach(_ref); | ||
this.tags = []; | ||
this.ctr = 0; | ||
} | ||
var StyleSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
var _proto = _StyleSheet.prototype; | ||
_proto.insert = _insert; | ||
_proto.flush = _flush; | ||
return _StyleSheet; | ||
return StyleSheet; | ||
}(); | ||
@@ -120,0 +117,0 @@ |
@@ -42,74 +42,71 @@ /* | ||
function _StyleSheet(options) { | ||
if (options === undefined) options = {}; | ||
this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy; // maxLength is how many rules we have per style tag, it's 65000 in speedy mode | ||
// because that's the upper limit in IE 10 TODO: make sure that is actually correct | ||
// it's 1 in dev because we insert source maps that map a single rule to a location | ||
// and you can only have one source map per style tag | ||
var StyleSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
function StyleSheet(options) { | ||
if (options === undefined) options = {}; | ||
this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy; // maxLength is how many rules we have per style tag, it's 65000 in speedy mode | ||
// because that's the upper limit in IE 10 TODO: make sure that is actually correct | ||
// it's 1 in dev because we insert source maps that map a single rule to a location | ||
// and you can only have one source map per style tag | ||
this.maxLength = options.maxLength || this.isSpeedy ? 65000 : 1; | ||
this.tags = []; | ||
this.ctr = 0; | ||
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets | ||
this.maxLength = options.maxLength || this.isSpeedy ? 65000 : 1; | ||
this.tags = []; | ||
this.ctr = 0; | ||
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets | ||
this.key = options.key || ''; // $FlowFixMe | ||
this.key = options.key || ''; | ||
this.container = options.container || ( // $FlowFixMe | ||
typeof document !== 'undefined' ? document.head : null); | ||
} | ||
this.container = options.container || (typeof document !== 'undefined' ? document.head : null); | ||
} | ||
var _proto = StyleSheet.prototype; | ||
function _insert(rule) { | ||
if (this.ctr % this.maxLength === 0) { | ||
var _tag = document.createElement('style'); | ||
_proto.insert = function insert(rule) { | ||
if (this.ctr % this.maxLength === 0) { | ||
var _tag = document.createElement('style'); | ||
_tag.setAttribute('data-emotion', this.key); | ||
_tag.setAttribute('data-emotion', this.key); | ||
if (this.nonce !== undefined) { | ||
_tag.setAttribute('nonce', this.nonce); | ||
} | ||
if (this.nonce !== undefined) { | ||
_tag.setAttribute('nonce', this.nonce); | ||
} | ||
_tag.appendChild(document.createTextNode('')); | ||
_tag.appendChild(document.createTextNode('')); | ||
this.container.appendChild(_tag); | ||
this.tags.push(_tag); | ||
} | ||
this.container.appendChild(_tag); | ||
this.tags.push(_tag); | ||
} | ||
var tag = this.tags[this.tags.length - 1]; | ||
var tag = this.tags[this.tags.length - 1]; | ||
if (this.isSpeedy) { | ||
var sheet = sheetForTag(tag); | ||
if (this.isSpeedy) { | ||
var sheet = sheetForTag(tag); | ||
try { | ||
// this is the ultrafast version, works across browsers | ||
// the big drawback is that the css won't be editable in devtools | ||
sheet.insertRule(rule, sheet.cssRules.length); | ||
} catch (e) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn("There was a problem inserting the following rule: \"" + rule + "\"", e); | ||
try { | ||
// this is the ultrafast version, works across browsers | ||
// the big drawback is that the css won't be editable in devtools | ||
sheet.insertRule(rule, sheet.cssRules.length); | ||
} catch (e) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn("There was a problem inserting the following rule: \"" + rule + "\"", e); | ||
} | ||
} | ||
} else { | ||
tag.appendChild(document.createTextNode(rule)); | ||
} | ||
} else { | ||
tag.appendChild(document.createTextNode(rule)); | ||
} | ||
this.ctr++; | ||
} | ||
this.ctr++; | ||
}; | ||
function _ref(tag) { | ||
return tag.parentNode.removeChild(tag); | ||
} | ||
_proto.flush = function flush() { | ||
// $FlowFixMe | ||
this.tags.forEach(function (tag) { | ||
return tag.parentNode.removeChild(tag); | ||
}); | ||
this.tags = []; | ||
this.ctr = 0; | ||
}; | ||
function _flush() { | ||
// $FlowFixMe | ||
this.tags.forEach(_ref); | ||
this.tags = []; | ||
this.ctr = 0; | ||
} | ||
var StyleSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
var _proto = _StyleSheet.prototype; | ||
_proto.insert = _insert; | ||
_proto.flush = _flush; | ||
return _StyleSheet; | ||
return StyleSheet; | ||
}(); | ||
@@ -116,0 +113,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.emotionSheet={})}(this,function(e){"use strict";function t(e){void 0===e&&(e={}),this.isSpeedy=void 0===e.speedy||e.speedy,this.maxLength=e.maxLength||this.isSpeedy?65e3:1,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key||"",this.container=e.container||("undefined"!=typeof document?document.head:null)}function n(e){if(this.ctr%this.maxLength==0){var t=document.createElement("style");t.setAttribute("data-emotion",this.key),void 0!==this.nonce&&t.setAttribute("nonce",this.nonce),t.appendChild(document.createTextNode("")),this.container.appendChild(t),this.tags.push(t)}var n=this.tags[this.tags.length-1];if(this.isSpeedy){var i=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(n);try{i.insertRule(e,i.cssRules.length)}catch(e){}}else n.appendChild(document.createTextNode(e));this.ctr++}function i(e){return e.parentNode.removeChild(e)}function s(){this.tags.forEach(i),this.tags=[],this.ctr=0}var o=function(){var e=t.prototype;return e.insert=n,e.flush=s,t}();e.StyleSheet=o,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.emotionSheet={})}(this,function(e){"use strict";var t=function(){function e(e){void 0===e&&(e={}),this.isSpeedy=void 0===e.speedy||e.speedy,this.maxLength=e.maxLength||this.isSpeedy?65e3:1,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key||"",this.container=e.container||("undefined"!=typeof document?document.head:null)}var t=e.prototype;return t.insert=function(e){if(this.ctr%this.maxLength==0){var t=document.createElement("style");t.setAttribute("data-emotion",this.key),void 0!==this.nonce&&t.setAttribute("nonce",this.nonce),t.appendChild(document.createTextNode("")),this.container.appendChild(t),this.tags.push(t)}var n=this.tags[this.tags.length-1];if(this.isSpeedy){var i=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(n);try{i.insertRule(e,i.cssRules.length)}catch(e){}}else n.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0},e}();e.StyleSheet=t,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@emotion/sheet", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "emotion's stylesheet", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -75,5 +75,5 @@ // @flow | ||
this.key = options.key || '' | ||
// $FlowFixMe | ||
this.container = | ||
options.container || | ||
// $FlowFixMe | ||
(typeof document !== 'undefined' ? document.head : null) | ||
@@ -80,0 +80,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29953
287