aliascss 1.5.5 → 1.5.6

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.
@@ -12,7 +12,7 @@ export let classPrinter = {
12
12
  flushQueued: false,
13
13
  styleTagExists: false,
14
14
  customCheck: false,
15
- useColon: true,
15
+ useColon: false,
16
16
  cls: {},
17
17
  kfs: {},
18
18
  kfNames: {},
@@ -262,6 +262,14 @@ export let classPrinter = {
262
262
  const result = this.compileElement(e, classList);
263
263
  statement += result ? result : '';
264
264
  });
265
+ const groupAttr = this.useColon ? /^class[-_:]/ : /^class[-_]/;
266
+ const groupOnly = (e) => !e.hasAttribute('class') && [...e.attributes].some((a) => groupAttr.test(a.name));
267
+ const all = [...$el.querySelectorAll('*')];
268
+ $el.querySelectorAll('template').forEach((t) => all.push(...t.content.querySelectorAll('*')));
269
+ all.filter(groupOnly).forEach((e) => {
270
+ const result = this.compileElement(e, classList);
271
+ statement += result ? result : '';
272
+ });
265
273
  return statement;
266
274
  },
267
275
  run(el) {
@@ -281,13 +289,30 @@ export let classPrinter = {
281
289
  const kfRoot = (el || document.body);
282
290
  const kfNodes = [kfRoot, ...kfRoot.querySelectorAll('*')];
283
291
  kfRoot.querySelectorAll('template').forEach((t) => kfNodes.push(...t.content.querySelectorAll('*')));
292
+ // kfNodes.forEach((node) => {
293
+ // for (const attr of node.attributes) {
294
+ // const m = attr.name.match(/^keyframes[-_:](.+)$/i);
295
+ // if (m) this.kfNames[m[1].toLowerCase()] = m[1];
296
+ // }
297
+ // });
298
+ // Elements with only a group attribute (class-card="…") aren't matched by [class],
299
+ // so they're collected here, in the loop that already reads every attribute.
300
+ const groupAttr = this.useColon ? /^class[-_:]/ : /^class[-_]/;
301
+ const groupOnly = [];
284
302
  kfNodes.forEach((node) => {
303
+ let hasGroup = false;
285
304
  for (const attr of node.attributes) {
286
305
  const m = attr.name.match(/^keyframes[-_:](.+)$/i);
287
306
  if (m)
288
307
  this.kfNames[m[1].toLowerCase()] = m[1];
308
+ if (groupAttr.test(attr.name))
309
+ hasGroup = true;
289
310
  }
311
+ // Elements with class are printed by the [class] pass below
312
+ if (hasGroup && !node.hasAttribute('class'))
313
+ groupOnly.push(node);
290
314
  });
315
+ groupOnly.forEach((node) => this.print(node));
291
316
  // <template> element
292
317
  Array.prototype.forEach.call($root.querySelectorAll('template'), (template) => {
293
318
  // Array.prototype.forEach.call(template.content.querySelectorAll('[class],[acss-class]'), (e) => {
package/lib/config.js CHANGED
@@ -9,8 +9,8 @@ const config = {
9
9
  useCSSModule: false,
10
10
  matchCSSModuleFunction: new RegExp('(?:' + 'x|@' + ')' + "[\\s*]?(`|\\([" + `"'])` + "([^)`]+)" + "(`|" + `["']` + "\\))"),
11
11
  // matchRegExp:/(?:(class|className|class[-_][\w-\[\]=_]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
12
- matchRegExp: /(?:(class|className|class[-_][\w-\[\]=_&:\(\)\~\*\$\^\|]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
13
- matchRegExpWithColon: /(?:(class|className|class[-_:][\w-\[\]=_&:\(\)\~\*\$\^\|]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
12
+ matchRegExp: /(?:(class|className|class[-_][\w-\[\]=_&:\(\)\~\*\$\^\|@]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
13
+ matchRegExpWithColon: /(?:(class|className|class[-_:][\w-\[\]=_&:\(\)\~\*\$\^\|@]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
14
14
  matchRegExpKeyFrame: /[\s](?:(keyframes[-_][\w-]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
15
15
  matchRegExpWithColonKeyFrame: /[\s](?:(keyframes[-_:][\w-]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
16
16
  createExtractorRegex: (fname) => new RegExp('(?:' + fname + ')' + "[\\s*]?(`|\\([" + `"'])` + "([^'`" + '"]+)' + "(`|" + `["']` + "\\))"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aliascss",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "AliasCSS is a CSS post processor.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",