Skip to content

Commit 42cc78d

Browse files
author
Maarten Staa
committed
Fix listDepth resetting on every call to matchST_ATTRIBUTE.
1 parent 86bee21 commit 42cc78d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/lexer/attribute.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"use strict";
77

88
module.exports = {
9+
attributeIndex: 0,
10+
attributeListDepth: {},
911
matchST_ATTRIBUTE: function () {
10-
let listDepth = 0;
1112
let ch = this.input();
1213
if (this.is_WHITESPACE()) {
1314
do {
@@ -18,11 +19,13 @@ module.exports = {
1819
}
1920
switch (ch) {
2021
case "]":
21-
if (listDepth === 0) {
22+
if (this.attributeListDepth[this.attributeIndex] === 0) {
23+
delete this.attributeListDepth[this.attributeIndex];
24+
this.attributeIndex--;
2225
this.popState();
2326
} else {
2427
/* istanbul ignore next */
25-
listDepth--;
28+
this.attributeListDepth[this.attributeIndex]--;
2629
}
2730
return "]";
2831
case "(":
@@ -42,7 +45,7 @@ module.exports = {
4245
case "!":
4346
return this.consume_TOKEN();
4447
case "[":
45-
listDepth++;
48+
this.attributeListDepth[this.attributeIndex]++;
4649
return "[";
4750
case ",":
4851
return ",";

src/lexer/scripting.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
case "#":
1919
if (this.version >= 800 && this._input[this.offset] === "[") {
2020
this.input();
21+
this.attributeListDepth[++this.attributeIndex] = 0;
2122
this.begin("ST_ATTRIBUTE");
2223
return this.tok.T_ATTRIBUTE;
2324
}

0 commit comments

Comments
 (0)