fix(compiler): markup lexer should not capture quotes in attribute value (#28055)
When tokenizing markup (e.g. HTML) element attributes can have quoted or unquoted values (e.g. `a=b` or `a="b"`). The `ATTR_VALUE` tokens were capturing the quotes, which was inconsistent and also affected source-mapping. Now the tokenizer captures additional `ATTR_QUOTE` tokens, which the HTML related parsers understand and factor into their token parsing. PR Close #28055
This commit is contained in:

committed by
Misko Hevery

parent
e6a00be014
commit
c0dac184cd
@ -429,8 +429,15 @@ import {humanizeDom, humanizeDomSourceSpans, humanizeLineColumn} from './ast_spe
|
||||
it('should report a value span for an attribute with a value', () => {
|
||||
const ast = parser.parse('<div bar="12"></div>', 'TestComp');
|
||||
const attr = (ast.rootNodes[0] as html.Element).attrs[0];
|
||||
expect(attr.valueSpan !.start.offset).toEqual(10);
|
||||
expect(attr.valueSpan !.end.offset).toEqual(12);
|
||||
});
|
||||
|
||||
it('should report a value span for an unquoted attribute value', () => {
|
||||
const ast = parser.parse('<div bar=12></div>', 'TestComp');
|
||||
const attr = (ast.rootNodes[0] as html.Element).attrs[0];
|
||||
expect(attr.valueSpan !.start.offset).toEqual(9);
|
||||
expect(attr.valueSpan !.end.offset).toEqual(13);
|
||||
expect(attr.valueSpan !.end.offset).toEqual(11);
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user