@hyperframes/lint 0.8.38 → 0.8.39

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.js CHANGED
@@ -14,12 +14,24 @@ function parseHtmlStructure(source) {
14
14
  const blocks = { script: [], style: [] };
15
15
  const openTagsByName = /* @__PURE__ */ new Map();
16
16
  const openBlocks = [];
17
+ let explicitOpenTag = null;
17
18
  const parser = new Parser(
18
19
  {
19
- onopentag(name) {
20
- const index = parser.startIndex;
20
+ onopentagname(name) {
21
+ let tokenStart = parser.endIndex - 1;
22
+ while (tokenStart >= parser.startIndex && !/[\t\n\f\r />]/.test(source.charAt(tokenStart))) {
23
+ tokenStart -= 1;
24
+ }
25
+ const index = source.indexOf("<", tokenStart + 1);
26
+ explicitOpenTag = index >= 0 && index < parser.endIndex && source.slice(index + 1, parser.endIndex).toLowerCase() === name ? { index, nameEnd: parser.endIndex } : null;
27
+ },
28
+ onopentag(name, _attrs, isImplied) {
29
+ const origin = !isImplied ? explicitOpenTag : null;
30
+ const index = origin?.index ?? parser.startIndex;
31
+ explicitOpenTag = null;
21
32
  const raw = source.slice(index, parser.endIndex + 1);
22
- const attrs = raw.slice(name.length + 1, -1).replace(/\s*\/$/, "");
33
+ const rawAttrs = origin ? source.slice(origin.nameEnd, parser.endIndex) : raw.slice(name.length + 1, -1);
34
+ const attrs = rawAttrs.replace(/\s*\/$/, "");
23
35
  const tag = { raw, name, attrs, index };
24
36
  tags.push(tag);
25
37
  const sameNameStack = openTagsByName.get(name) ?? [];