@markuplint/vue-parser 3.0.0 → 3.2.0

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.
Files changed (2) hide show
  1. package/lib/attr.js +85 -13
  2. package/package.json +4 -4
package/lib/attr.js CHANGED
@@ -10,24 +10,96 @@ function attr(attr) {
10
10
  }
11
11
  return attr;
12
12
  }
13
- /**
14
- * If data-binding attributes
15
- */
16
- const [, directive, potentialName] = attr.name.raw.match(/^(v-bind:|:)(.+)$/i) || [];
17
- if (directive && potentialName) {
18
- if (duplicatableAttrs.includes(potentialName.toLowerCase())) {
19
- attr.isDuplicatable = true;
13
+ {
14
+ /**
15
+ * `v-on`
16
+ */
17
+ const [, directive, potentialName, modifier] = attr.name.raw.match(/^(v-on:|@)([^.]+)(?:\.([^.]))?$/i) || [];
18
+ if (directive && potentialName) {
19
+ return {
20
+ ...attr,
21
+ potentialName: `on${potentialName.toLowerCase()}`,
22
+ isDynamicValue: true,
23
+ // @ts-ignore
24
+ _modifier: modifier,
25
+ };
26
+ }
27
+ }
28
+ {
29
+ /**
30
+ * `v-bind`
31
+ */
32
+ const [, directive, potentialName, modifier] = attr.name.raw.match(/^(v-bind:|:)([^.]+)(?:\.([^.]))?$/i) || [];
33
+ if (directive && potentialName) {
34
+ if (duplicatableAttrs.includes(potentialName.toLowerCase())) {
35
+ attr.isDuplicatable = true;
36
+ }
37
+ if (!modifier) {
38
+ return {
39
+ ...attr,
40
+ potentialName,
41
+ isDynamicValue: true,
42
+ };
43
+ }
44
+ switch (modifier) {
45
+ case '.attr': {
46
+ return {
47
+ ...attr,
48
+ potentialName,
49
+ isDynamicValue: true,
50
+ // @ts-ignore
51
+ _modifier: modifier,
52
+ };
53
+ }
54
+ // TODO: Supporting for `prop` and `camel` https://github.com/markuplint/markuplint/pull/681
55
+ case '.prop':
56
+ case '.camel':
57
+ default: {
58
+ const name = `v-bind:${potentialName}${modifier !== null && modifier !== void 0 ? modifier : ''}`;
59
+ return {
60
+ ...attr,
61
+ potentialName: attr.name.raw !== name ? name : undefined,
62
+ isDirective: true,
63
+ // @ts-ignore
64
+ _modifier: modifier,
65
+ };
66
+ }
67
+ }
68
+ }
69
+ }
70
+ {
71
+ /**
72
+ * `v-model`
73
+ */
74
+ const [, directive, modifier] = attr.name.raw.match(/^(v-model)(?:\.([^.]))?$/i) || [];
75
+ if (directive) {
76
+ // TODO: Supporting for `v-model` https://github.com/markuplint/markuplint/pull/681
77
+ return {
78
+ ...attr,
79
+ isDirective: true,
80
+ // @ts-ignore
81
+ _modifier: modifier,
82
+ };
83
+ }
84
+ }
85
+ {
86
+ /**
87
+ * `v-slot`
88
+ */
89
+ const [, , slotName] = attr.name.raw.match(/^(v-slot:|#)(.+)$/i) || [];
90
+ const name = `v-slot:${slotName}`;
91
+ if (slotName) {
92
+ return {
93
+ ...attr,
94
+ potentialName: attr.name.raw !== name ? name : undefined,
95
+ isDirective: true,
96
+ };
20
97
  }
21
- return {
22
- ...attr,
23
- potentialName,
24
- isDynamicValue: true,
25
- };
26
98
  }
27
99
  /**
28
100
  * If directives
29
101
  */
30
- if (/^(?:v-|@)/.test(attr.name.raw)) {
102
+ if (/^v-/.test(attr.name.raw)) {
31
103
  return {
32
104
  ...attr,
33
105
  isDirective: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/vue-parser",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "Vue parser for markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -16,11 +16,11 @@
16
16
  "clean": "tsc --build --clean"
17
17
  },
18
18
  "dependencies": {
19
- "@markuplint/html-parser": "3.0.0",
19
+ "@markuplint/html-parser": "3.2.0",
20
20
  "@markuplint/ml-ast": "3.0.0-rc.5",
21
- "@markuplint/parser-utils": "3.0.0",
21
+ "@markuplint/parser-utils": "3.2.0",
22
22
  "tslib": "^2.4.1",
23
23
  "vue-eslint-parser": "^9.1.0"
24
24
  },
25
- "gitHead": "51af6a64bb8da54376a138f19e3f15a2f759a967"
25
+ "gitHead": "26b04e045d91e29befca34c10dda2147b1bca9c7"
26
26
  }