@unocss/transformer-attributify-jsx 0.50.1 → 0.50.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -11,7 +11,7 @@ function createFilter(include, exclude) {
11
11
  return includePattern.some((p) => id.match(p));
12
12
  };
13
13
  }
14
- const elementRE = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/gs;
14
+ const elementRE = /<([^>\s]*\s)((?:'.*?'|".*?"|`.*?`|\{.*?\}|[^>]*?)*)/g;
15
15
  const attributeRE = /([a-zA-Z()#][\[?a-zA-Z0-9-_:()#%\]?]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
16
16
  const classFilterRE = /(className|class)\s*=\s*\{[^\}]*\}/i;
17
17
  const curlybraceRE = /\w+\s?=\s?\{.+?\}/g;
@@ -41,10 +41,10 @@ function transformerAttributifyJsx(options = {}) {
41
41
  async transform(code, _, { uno }) {
42
42
  const tasks = [];
43
43
  for (const item of Array.from(code.original.matchAll(elementRE))) {
44
- const classNamePart = item[3].match(classFilterRE);
45
- let attributifyPart = item[3];
44
+ const classNamePart = item[2].match(classFilterRE);
45
+ let attributifyPart = item[2];
46
46
  if (classNamePart)
47
- attributifyPart = item[3].replace(classFilterRE, " ".repeat(classNamePart[0].length));
47
+ attributifyPart = item[2].replace(classFilterRE, " ".repeat(classNamePart[0].length));
48
48
  if (curlybraceRE.test(attributifyPart))
49
49
  attributifyPart = attributifyPart.replace(curlybraceRE, (match) => " ".repeat(match.length));
50
50
  for (const attr of attributifyPart.matchAll(attributeRE)) {
@@ -53,7 +53,7 @@ function transformerAttributifyJsx(options = {}) {
53
53
  continue;
54
54
  tasks.push(uno.parseToken(matchedRule).then((matched) => {
55
55
  if (matched) {
56
- const tag = item[2];
56
+ const tag = item[1];
57
57
  const startIdx = (item.index || 0) + (attr.index || 0) + tag.length + 1;
58
58
  const endIdx = startIdx + matchedRule.length;
59
59
  code.overwrite(startIdx, endIdx, `${matchedRule}=""`);
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ function createFilter(include, exclude) {
9
9
  return includePattern.some((p) => id.match(p));
10
10
  };
11
11
  }
12
- const elementRE = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/gs;
12
+ const elementRE = /<([^>\s]*\s)((?:'.*?'|".*?"|`.*?`|\{.*?\}|[^>]*?)*)/g;
13
13
  const attributeRE = /([a-zA-Z()#][\[?a-zA-Z0-9-_:()#%\]?]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
14
14
  const classFilterRE = /(className|class)\s*=\s*\{[^\}]*\}/i;
15
15
  const curlybraceRE = /\w+\s?=\s?\{.+?\}/g;
@@ -39,10 +39,10 @@ function transformerAttributifyJsx(options = {}) {
39
39
  async transform(code, _, { uno }) {
40
40
  const tasks = [];
41
41
  for (const item of Array.from(code.original.matchAll(elementRE))) {
42
- const classNamePart = item[3].match(classFilterRE);
43
- let attributifyPart = item[3];
42
+ const classNamePart = item[2].match(classFilterRE);
43
+ let attributifyPart = item[2];
44
44
  if (classNamePart)
45
- attributifyPart = item[3].replace(classFilterRE, " ".repeat(classNamePart[0].length));
45
+ attributifyPart = item[2].replace(classFilterRE, " ".repeat(classNamePart[0].length));
46
46
  if (curlybraceRE.test(attributifyPart))
47
47
  attributifyPart = attributifyPart.replace(curlybraceRE, (match) => " ".repeat(match.length));
48
48
  for (const attr of attributifyPart.matchAll(attributeRE)) {
@@ -51,7 +51,7 @@ function transformerAttributifyJsx(options = {}) {
51
51
  continue;
52
52
  tasks.push(uno.parseToken(matchedRule).then((matched) => {
53
53
  if (matched) {
54
- const tag = item[2];
54
+ const tag = item[1];
55
55
  const startIdx = (item.index || 0) + (attr.index || 0) + tag.length + 1;
56
56
  const endIdx = startIdx + matchedRule.length;
57
57
  code.overwrite(startIdx, endIdx, `${matchedRule}=""`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/transformer-attributify-jsx",
3
- "version": "0.50.1",
3
+ "version": "0.50.3",
4
4
  "description": "Support valueless attributify in JSX/TSX.",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "dist"
34
34
  ],
35
35
  "dependencies": {
36
- "@unocss/core": "0.50.1"
36
+ "@unocss/core": "0.50.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "magic-string": "^0.30.0"