Skip to content

Commit

Permalink
perf(runtime): less operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Anidetrix committed Mar 24, 2020
1 parent 9b7e648 commit 7375fe7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 64 deletions.
4 changes: 1 addition & 3 deletions runtime/inject-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ export default (css, options = {}) => {
}

// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);

if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down
76 changes: 19 additions & 57 deletions test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -124,9 +122,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -215,9 +211,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -302,9 +296,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -593,9 +585,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -680,9 +670,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -785,9 +773,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -872,9 +858,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1110,9 +1094,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1191,9 +1173,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1272,9 +1252,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1356,9 +1334,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1447,9 +1423,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1517,9 +1491,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1587,9 +1559,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1657,9 +1627,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1730,9 +1698,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1800,9 +1766,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down Expand Up @@ -1887,9 +1851,7 @@ var injector_14187a73 = (css, options = {}) => {
}
// strip potential UTF-8 BOM if css was read from a file
if (css.charCodeAt(0) === 0xfeff) {
css = css.slice(1, 1 + css.length);
}
if (css.charCodeAt(0) === 0xfeff) css = css.slice(1);
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText += css;
Expand Down
21 changes: 17 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,14 @@ css-tree@1.0.0-alpha.37:
mdn-data "2.0.4"
source-map "^0.6.1"

css-tree@1.0.0-alpha.39:
version "1.0.0-alpha.39"
resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.0.0-alpha.39.tgz#2bff3ffe1bb3f776cf7eefd91ee5cba77a149eeb"
integrity sha512-7UvkEYgBAHRG9Nt980lYxjsTrCyHFN53ky3wVsDkiMdVqylqRt+Zc+jm5qw7/qyOvN2dHSYtX0e4MbCCExSvnA==
dependencies:
mdn-data "2.0.6"
source-map "^0.6.1"

css-what@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/css-what/-/css-what-3.2.1.tgz#f4a8f12421064621b456755e34a03a2c22df5da1"
Expand Down Expand Up @@ -2527,11 +2535,11 @@ cssnano@^4.1.10:
postcss "^7.0.0"

csso@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/csso/-/csso-4.0.2.tgz#e5f81ab3a56b8eefb7f0092ce7279329f454de3d"
integrity sha512-kS7/oeNVXkHWxby5tHVxlhjizRCSv8QdU7hB2FpdAibDU8FjTAolhNjKNTiLzXtUrKT6HwClE81yXwEk1309wg==
version "4.0.3"
resolved "https://registry.yarnpkg.com/csso/-/csso-4.0.3.tgz#0d9985dc852c7cc2b2cacfbbe1079014d1a8e903"
integrity sha512-NL3spysxUkcrOgnpsT4Xdl2aiEiBG6bXswAABQVHcMrfjjBisFOKwLDOmf4wf32aPdcJws1zds2B0Rg+jqMyHQ==
dependencies:
css-tree "1.0.0-alpha.37"
css-tree "1.0.0-alpha.39"

cssom@^0.4.1:
version "0.4.4"
Expand Down Expand Up @@ -5142,6 +5150,11 @@ mdn-data@2.0.4:
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b"
integrity sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==

mdn-data@2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.6.tgz#852dc60fcaa5daa2e8cf6c9189c440ed3e042978"
integrity sha512-rQvjv71olwNHgiTbfPZFkJtjNMciWgswYeciZhtvWLO8bmX3TnhyA62I6sTWOyZssWHJJjY6/KiWwqQsWWsqOA==

meow@5.0.0, meow@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4"
Expand Down

0 comments on commit 7375fe7

Please sign in to comment.