mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Allow escaped " literals in the SyntaxScopeMap
In order to pass a quote literal to the postcss-selector-parser, it needs to be escaped. However, this escaping is not removed by the parser in the yielded value token, so in this commit I replace any escaped quote literals with unescaped quotes after we trim the outer quotes off of the string.
This commit is contained in:
@@ -49,13 +49,15 @@ describe('SyntaxScopeMap', () => {
|
||||
const map = new SyntaxScopeMap({
|
||||
'"b"': 'w',
|
||||
'a > "b"': 'x',
|
||||
'a > "b":nth-child(1)': 'y'
|
||||
'a > "b":nth-child(1)': 'y',
|
||||
'"\\""': 'z'
|
||||
})
|
||||
|
||||
expect(map.get(['b'], [0], true)).toBe(undefined)
|
||||
expect(map.get(['b'], [0], false)).toBe('w')
|
||||
expect(map.get(['a', 'b'], [0, 0], false)).toBe('x')
|
||||
expect(map.get(['a', 'b'], [0, 1], false)).toBe('y')
|
||||
expect(map.get(['a', '"'], [0, 1], false)).toBe('z')
|
||||
})
|
||||
|
||||
it('supports the wildcard selector', () => {
|
||||
|
||||
@@ -36,7 +36,7 @@ class SyntaxScopeMap {
|
||||
|
||||
case 'string':
|
||||
if (!currentTable) currentTable = this.anonymousScopeTable
|
||||
const value = termNode.value.slice(1, -1)
|
||||
const value = termNode.value.slice(1, -1).replace(/\\"/g, '"')
|
||||
if (!currentTable[value]) currentTable[value] = {}
|
||||
currentTable = currentTable[value]
|
||||
if (currentIndexValue != null) {
|
||||
|
||||
Reference in New Issue
Block a user