@markuplint/svelte-parser 3.3.1 → 3.4.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.
package/lib/attr.js CHANGED
@@ -46,7 +46,7 @@ function attr(attr, rawHTML) {
46
46
  token.isDynamicValue = true;
47
47
  }
48
48
  const [baseName, subName] = token.name.raw.split(':');
49
- if (baseName.toLowerCase() === 'class') {
49
+ if ((baseName === null || baseName === void 0 ? void 0 : baseName.toLowerCase()) === 'class') {
50
50
  token.isDuplicatable = true;
51
51
  if (subName) {
52
52
  token.potentialName = 'class';
@@ -9,6 +9,7 @@ const reBeforeStructure = /^(\s*)([^\x00-\x1f\x7f-\x9f {>/=]+)(\s*)(=)(\s*){(\s*
9
9
  const reBeforeStructureWithoutName = /^{(\s*)$/;
10
10
  const reAfterStructure = /(\s*)}/;
11
11
  function directiveTokenizer(raw, rawValue, line, col, startOffset) {
12
+ var _a, _b, _c, _d, _e;
12
13
  let spacesBeforeAttrString = '';
13
14
  let nameChars = '';
14
15
  let spacesBeforeEqualChars = '';
@@ -16,16 +17,16 @@ function directiveTokenizer(raw, rawValue, line, col, startOffset) {
16
17
  let spacesAfterEqualChars = '';
17
18
  let valueChars = '';
18
19
  const [before, after] = raw.split(rawValue);
19
- const beforeMatchedMap = before.match(reBeforeStructure);
20
- const beforeWithoutNameMatchedMap = before.match(reBeforeStructureWithoutName);
21
- const afterMatchedMap = after.match(reAfterStructure);
20
+ const beforeMatchedMap = before === null || before === void 0 ? void 0 : before.match(reBeforeStructure);
21
+ const beforeWithoutNameMatchedMap = before === null || before === void 0 ? void 0 : before.match(reBeforeStructureWithoutName);
22
+ const afterMatchedMap = after === null || after === void 0 ? void 0 : after.match(reAfterStructure);
22
23
  if (beforeMatchedMap && afterMatchedMap) {
23
- spacesBeforeAttrString = beforeMatchedMap[1];
24
- nameChars = beforeMatchedMap[2];
25
- spacesBeforeEqualChars = beforeMatchedMap[3] || '';
24
+ spacesBeforeAttrString = (_a = beforeMatchedMap[1]) !== null && _a !== void 0 ? _a : '';
25
+ nameChars = (_b = beforeMatchedMap[2]) !== null && _b !== void 0 ? _b : '';
26
+ spacesBeforeEqualChars = (_c = beforeMatchedMap[3]) !== null && _c !== void 0 ? _c : '';
26
27
  equalChars = beforeMatchedMap[4] || null;
27
- spacesAfterEqualChars = beforeMatchedMap[5] || '';
28
- valueChars = (beforeMatchedMap[6] || '') + rawValue + (afterMatchedMap[1] || '');
28
+ spacesAfterEqualChars = (_d = beforeMatchedMap[5]) !== null && _d !== void 0 ? _d : '';
29
+ valueChars = ((_e = beforeMatchedMap[6]) !== null && _e !== void 0 ? _e : '') + rawValue + (afterMatchedMap[1] || '');
29
30
  }
30
31
  else if (beforeWithoutNameMatchedMap && afterMatchedMap) {
31
32
  valueChars = (beforeWithoutNameMatchedMap[1] || '') + rawValue + (afterMatchedMap[1] || '');
package/lib/nodeize.js CHANGED
@@ -6,7 +6,7 @@ const parser_utils_1 = require("@markuplint/parser-utils");
6
6
  const attr_1 = require("./attr");
7
7
  const traverse_1 = require("./traverse");
8
8
  function nodeize(originNode, prevNode, parentNode, rawHtml, options) {
9
- var _a, _b;
9
+ var _a, _b, _c, _d;
10
10
  const nextNode = null;
11
11
  const { startOffset, endOffset, startLine, endLine, startCol, endCol, raw } = (0, parser_utils_1.sliceFragment)(rawHtml, originNode.start, originNode.end);
12
12
  const parentNamespace = parentNode && 'namespace' in parentNode ? parentNode.namespace : 'http://www.w3.org/1999/xhtml';
@@ -54,7 +54,7 @@ function nodeize(originNode, prevNode, parentNode, rawHtml, options) {
54
54
  const children = originNode.children || [];
55
55
  const reEndTag = new RegExp(`</${originNode.name}\\s*>$`, 'i');
56
56
  const startTagEndOffset = children.length
57
- ? children[0].start
57
+ ? (_b = (_a = children[0]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0
58
58
  : raw.replace(reEndTag, '').length + startOffset;
59
59
  const startTagLocation = (0, parser_utils_1.sliceFragment)(rawHtml, startOffset, startTagEndOffset);
60
60
  let endTag = null;
@@ -150,7 +150,7 @@ function nodeize(originNode, prevNode, parentNode, rawHtml, options) {
150
150
  let then = null;
151
151
  if (originNode.then) {
152
152
  const thenNode = originNode.then;
153
- const thenTag = (0, parser_utils_1.sliceFragment)(rawHtml, thenNode.start, (_a = (thenNode.children && thenNode.children[0] && thenNode.children[0].start)) !== null && _a !== void 0 ? _a : thenNode.end);
153
+ const thenTag = (0, parser_utils_1.sliceFragment)(rawHtml, thenNode.start, (_c = (thenNode.children && thenNode.children[0] && thenNode.children[0].start)) !== null && _c !== void 0 ? _c : thenNode.end);
154
154
  then = {
155
155
  uuid: (0, parser_utils_1.uuid)(),
156
156
  ...thenTag,
@@ -169,7 +169,7 @@ function nodeize(originNode, prevNode, parentNode, rawHtml, options) {
169
169
  let awaitCatch = null;
170
170
  if (originNode.catch) {
171
171
  const awaitCatchNode = originNode.catch;
172
- const awaitCatchTag = (0, parser_utils_1.sliceFragment)(rawHtml, awaitCatchNode.start, (_b = (awaitCatchNode.children && awaitCatchNode.children[0] && awaitCatchNode.children[0].start)) !== null && _b !== void 0 ? _b : awaitCatchNode.end);
172
+ const awaitCatchTag = (0, parser_utils_1.sliceFragment)(rawHtml, awaitCatchNode.start, (_d = (awaitCatchNode.children && awaitCatchNode.children[0] && awaitCatchNode.children[0].start)) !== null && _d !== void 0 ? _d : awaitCatchNode.end);
173
173
  awaitCatch = {
174
174
  uuid: (0, parser_utils_1.uuid)(),
175
175
  ...awaitCatchTag,
@@ -249,9 +249,12 @@ function nodeize(originNode, prevNode, parentNode, rawHtml, options) {
249
249
  }
250
250
  exports.nodeize = nodeize;
251
251
  function solveCtrlBlock(ctrlName, originNode, raw, rawHtml, startOffset, parentNode, prevNode, nextNode, options) {
252
+ var _a, _b, _c, _d;
252
253
  const children = originNode.children || [];
253
254
  const reEndTag = new RegExp(`{/${ctrlName}}$`, 'i');
254
- const startTagEndOffset = children.length ? children[0].start : raw.replace(reEndTag, '').length + startOffset;
255
+ const startTagEndOffset = children.length
256
+ ? (_b = (_a = children[0]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0
257
+ : raw.replace(reEndTag, '').length + startOffset;
255
258
  const startTagLocation = (0, parser_utils_1.sliceFragment)(rawHtml, startOffset, startTagEndOffset);
256
259
  let endTag = null;
257
260
  const endTagRawMatched = raw.match(reEndTag);
@@ -281,7 +284,9 @@ function solveCtrlBlock(ctrlName, originNode, raw, rawHtml, startOffset, parentN
281
284
  let elseTag = null;
282
285
  if (originNode.else) {
283
286
  const elseNode = originNode.else;
284
- const elseTagStartOffset = children.length ? children[children.length - 1].end : startTagLocation.endOffset;
287
+ const elseTagStartOffset = children.length
288
+ ? (_d = (_c = children[children.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0
289
+ : startTagLocation.endOffset;
285
290
  const elseTagLocation = (0, parser_utils_1.sliceFragment)(rawHtml, elseTagStartOffset, elseNode.start);
286
291
  elseTag = {
287
292
  uuid: (0, parser_utils_1.uuid)(),
package/lib/traverse.js CHANGED
@@ -12,7 +12,11 @@ function traverse(astNodes, parentNode = null, rawHtml, options) {
12
12
  }
13
13
  let node;
14
14
  if (Array.isArray(nodes)) {
15
- node = nodes[nodes.length - 1];
15
+ const lastNode = nodes[nodes.length - 1];
16
+ if (!lastNode) {
17
+ continue;
18
+ }
19
+ node = lastNode;
16
20
  }
17
21
  else {
18
22
  node = nodes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/svelte-parser",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
4
4
  "description": "Svelte 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.3.1",
19
+ "@markuplint/html-parser": "3.4.0",
20
20
  "@markuplint/ml-ast": "3.0.0",
21
- "@markuplint/parser-utils": "3.3.0",
21
+ "@markuplint/parser-utils": "3.4.0",
22
22
  "svelte": "^3.55.0",
23
23
  "tslib": "^2.4.1"
24
24
  },
25
- "gitHead": "f19e7de726cf01d53342bc5513c30da75d28da63"
25
+ "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
26
26
  }