Skip to content

Commit

Permalink
feat: recognise truncated CSS better
Browse files Browse the repository at this point in the history
  • Loading branch information
revelt committed Mar 3, 2021
1 parent a1ef93b commit 2d82a42
Show file tree
Hide file tree
Showing 9 changed files with 917 additions and 280 deletions.
2 changes: 1 addition & 1 deletion packages/codsen-tokenizer/coverage/coverage-summary.json
@@ -1 +1 @@
{"total":{"lines":{"total":963,"covered":900,"skipped":0,"pct":93.46},"statements":{"total":992,"covered":927,"skipped":0,"pct":93.45},"functions":{"total":43,"covered":41,"skipped":0,"pct":95.35},"branches":{"total":1535,"covered":1408,"skipped":0,"pct":91.73}}}
{"total":{"lines":{"total":965,"covered":902,"skipped":0,"pct":93.47},"statements":{"total":994,"covered":929,"skipped":0,"pct":93.46},"functions":{"total":43,"covered":41,"skipped":0,"pct":95.35},"branches":{"total":1542,"covered":1416,"skipped":0,"pct":91.83}}}
10 changes: 8 additions & 2 deletions packages/codsen-tokenizer/dist/codsen-tokenizer.cjs.js
Expand Up @@ -2202,7 +2202,9 @@ function tokenizer(str, originalOpts) {
// so that we can catch it later validating prop names
//
!rightVal || !":/}".includes(str[rightVal]) || // mind the rogue closings .a{x}}
str[_i] === "}" && str[rightVal] === "}")) && ( // also, regarding the slash,
str[_i] === "}" && str[rightVal] === "}") || // <style>.a{b!}
// ^
str[_i] === "!") && ( // also, regarding the slash,
// <div style="//color: red;">
// ^
// don't close here, continue, gather "//color"
Expand Down Expand Up @@ -2262,7 +2264,9 @@ function tokenizer(str, originalOpts) {
// this is

if ( // either semi but no colon
nextColon === -1 && nextSemi !== -1 || !(nextColon !== -1 && nextSemi !== -1 && nextColon < nextSemi)) {
(nextColon === -1 && nextSemi !== -1 || !(nextColon !== -1 && nextSemi !== -1 && nextColon < nextSemi)) && !"{}".includes(str[_i]) && rightVal && ( // <style>.a{b!}
// ^
!"!".includes(str[_i]) || !"{};'\"".includes(str[rightVal]))) {
// <div style="float.left;">
// ^
// we're here
Expand All @@ -2274,6 +2278,8 @@ function tokenizer(str, originalOpts) {
// ^
// we're here
property.propertyEnds = null;
} else if (str[_i] === "!") {
property.importantStarts = _i;
}
}
} // catch the colon of a css property
Expand Down
10 changes: 8 additions & 2 deletions packages/codsen-tokenizer/dist/codsen-tokenizer.dev.umd.js
Expand Up @@ -5822,7 +5822,9 @@ function tokenizer(str, originalOpts) {
// so that we can catch it later validating prop names
//
!rightVal || !":/}".includes(str[rightVal]) || // mind the rogue closings .a{x}}
str[_i] === "}" && str[rightVal] === "}")) && ( // also, regarding the slash,
str[_i] === "}" && str[rightVal] === "}") || // <style>.a{b!}
// ^
str[_i] === "!") && ( // also, regarding the slash,
// <div style="//color: red;">
// ^
// don't close here, continue, gather "//color"
Expand Down Expand Up @@ -5882,7 +5884,9 @@ function tokenizer(str, originalOpts) {
// this is

if ( // either semi but no colon
nextColon === -1 && nextSemi !== -1 || !(nextColon !== -1 && nextSemi !== -1 && nextColon < nextSemi)) {
(nextColon === -1 && nextSemi !== -1 || !(nextColon !== -1 && nextSemi !== -1 && nextColon < nextSemi)) && !"{}".includes(str[_i]) && rightVal && ( // <style>.a{b!}
// ^
!"!".includes(str[_i]) || !"{};'\"".includes(str[rightVal]))) {
// <div style="float.left;">
// ^
// we're here
Expand All @@ -5894,6 +5898,8 @@ function tokenizer(str, originalOpts) {
// ^
// we're here
property.propertyEnds = null;
} else if (str[_i] === "!") {
property.importantStarts = _i;
}
}
} // catch the colon of a css property
Expand Down
10 changes: 8 additions & 2 deletions packages/codsen-tokenizer/dist/codsen-tokenizer.esm.js
Expand Up @@ -2173,7 +2173,9 @@ function tokenizer(str, originalOpts) {
// so that we can catch it later validating prop names
//
!rightVal || !`:/}`.includes(str[rightVal]) || // mind the rogue closings .a{x}}
str[i] === "}" && str[rightVal] === "}")) && ( // also, regarding the slash,
str[i] === "}" && str[rightVal] === "}") || // <style>.a{b!}
// ^
str[i] === "!") && ( // also, regarding the slash,
// <div style="//color: red;">
// ^
// don't close here, continue, gather "//color"
Expand Down Expand Up @@ -2233,7 +2235,9 @@ function tokenizer(str, originalOpts) {
// this is

if ( // either semi but no colon
nextColon === -1 && nextSemi !== -1 || !(nextColon !== -1 && nextSemi !== -1 && nextColon < nextSemi)) {
(nextColon === -1 && nextSemi !== -1 || !(nextColon !== -1 && nextSemi !== -1 && nextColon < nextSemi)) && !`{}`.includes(str[i]) && rightVal && ( // <style>.a{b!}
// ^
!`!`.includes(str[i]) || !`{};'"`.includes(str[rightVal]))) {
// <div style="float.left;">
// ^
// we're here
Expand All @@ -2245,6 +2249,8 @@ function tokenizer(str, originalOpts) {
// ^
// we're here
property.propertyEnds = null;
} else if (str[i] === "!") {
property.importantStarts = i;
}
}
} // catch the colon of a css property
Expand Down
2 changes: 1 addition & 1 deletion packages/codsen-tokenizer/dist/codsen-tokenizer.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/codsen-tokenizer/dist/codsen-tokenizer.umd.js

Large diffs are not rendered by default.

0 comments on commit 2d82a42

Please sign in to comment.