Skip to content

Commit

Permalink
added Selectors Level 4 flag to force case insensitive match for attr…
Browse files Browse the repository at this point in the history
…ibute selectors [name='MiXeD' i]
  • Loading branch information
dperini committed Oct 1, 2017
1 parent 8367599 commit cd77668
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/nwmatcher-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@

attrcheck = '(' + quotedvalue + '|' + identifier + ')';
attributes = whitespace + '*(' + identifier + '(?::' + identifier + ')?)' +
whitespace + '*(?:' + operators + whitespace + '*' + attrcheck + ')?' + whitespace + '*';
whitespace + '*(?:' + operators + whitespace + '*' + attrcheck + ')?' + whitespace + '*' + '(i)?' + whitespace + '*';
attrmatcher = attributes.replace(attrcheck, '([\\x22\\x27]*)((?:\\\\?.)*?)\\3');

pseudoclass = '((?:' +
Expand Down Expand Up @@ -504,7 +504,7 @@
test = 'false';
if (match[2] && match[4] && (test = Operators[match[2]])) {
match[4] = (/\\/).test(match[4]) ? convertEscapes(match[4]) : match[4];
type = XML_DOCUMENT ? 0 : HTML_TABLE[expr.toLowerCase()];
type = match[5] == 'i' || HTML_TABLE[expr.toLowerCase()];
test = test.replace(/\%m/g, type ? match[4].toLowerCase() : match[4]);
} else if (match[2] == '!=' || match[2] == '=') {
test = 'n' + match[2] + '=""';
Expand Down
4 changes: 2 additions & 2 deletions src/nwmatcher-noqsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@

attrcheck = '(' + quotedvalue + '|' + identifier + ')';
attributes = whitespace + '*(' + identifier + '(?::' + identifier + ')?)' +
whitespace + '*(?:' + operators + whitespace + '*' + attrcheck + ')?' + whitespace + '*';
whitespace + '*(?:' + operators + whitespace + '*' + attrcheck + ')?' + whitespace + '*' + '(i)?' + whitespace + '*';
attrmatcher = attributes.replace(attrcheck, '([\\x22\\x27]*)((?:\\\\?.)*?)\\3');

pseudoclass = '((?:' +
Expand Down Expand Up @@ -554,7 +554,7 @@
test = 'false';
if (match[2] && match[4] && (test = Operators[match[2]])) {
match[4] = (/\\/).test(match[4]) ? convertEscapes(match[4]) : match[4];
type = XML_DOCUMENT ? 0 : HTML_TABLE[expr.toLowerCase()];
type = match[5] == 'i' || HTML_TABLE[expr.toLowerCase()];
test = test.replace(/\%m/g, type ? match[4].toLowerCase() : match[4]);
} else if (match[2] == '!=' || match[2] == '=') {
test = 'n' + match[2] + '=""';
Expand Down
4 changes: 2 additions & 2 deletions src/nwmatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@
// build attribute string
attrcheck = '(' + quotedvalue + '|' + identifier + ')';
attributes = whitespace + '*(' + identifier + '(?::' + identifier + ')?)' +
whitespace + '*(?:' + operators + whitespace + '*' + attrcheck + ')?' + whitespace + '*';
whitespace + '*(?:' + operators + whitespace + '*' + attrcheck + ')?' + whitespace + '*' + '(i)?' + whitespace + '*';
attrmatcher = attributes.replace(attrcheck, '([\\x22\\x27]*)((?:\\\\?.)*?)\\3');

// build pseudoclass string
Expand Down Expand Up @@ -1110,7 +1110,7 @@
if (match[2] && match[4] && (test = Operators[match[2]])) {
match[4] = (/\\/).test(match[4]) ? convertEscapes(match[4]) : match[4];
// case treatment depends on document type
type = XML_DOCUMENT ? 0 : HTML_TABLE[expr.toLowerCase()];
type = match[5] == 'i' || HTML_TABLE[expr.toLowerCase()];
test = test.replace(/\%m/g, type ? match[4].toLowerCase() : match[4]);
} else if (match[2] == '!=' || match[2] == '=') {
test = 'n' + match[2] + '=""';
Expand Down

0 comments on commit cd77668

Please sign in to comment.