diff --git a/compiler/parse/state/tag.js b/compiler/parse/state/tag.js index 457ed4f950..e8c627c93a 100644 --- a/compiler/parse/state/tag.js +++ b/compiler/parse/state/tag.js @@ -57,12 +57,12 @@ export default function tag ( parser ) { const lastChild = element.children[ element.children.length - 1 ]; if ( firstChild.type === 'Text' ) { - firstChild.data = trimStart( decodeCharacterReferences( firstChild.data ) ); + firstChild.data = trimStart( firstChild.data ); if ( !firstChild.data ) element.children.shift(); } if ( lastChild.type === 'Text' ) { - lastChild.data = trimEnd( decodeCharacterReferences( lastChild.data ) ); + lastChild.data = trimEnd( lastChild.data ); if ( !lastChild.data ) element.children.pop(); } } diff --git a/compiler/parse/state/text.js b/compiler/parse/state/text.js index 8a0c9046a7..ee42dd25e3 100644 --- a/compiler/parse/state/text.js +++ b/compiler/parse/state/text.js @@ -1,3 +1,5 @@ +import { decodeCharacterReferences } from '../utils/html.js'; + export default function text ( parser ) { const start = parser.index; @@ -11,7 +13,7 @@ export default function text ( parser ) { start, end: parser.index, type: 'Text', - data + data: decodeCharacterReferences( data ) }); return null; diff --git a/test/parser/convert-entities-in-element/input.html b/test/parser/convert-entities-in-element/input.html new file mode 100644 index 0000000000..bc5c086536 --- /dev/null +++ b/test/parser/convert-entities-in-element/input.html @@ -0,0 +1 @@ +
Hello & World
diff --git a/test/parser/convert-entities-in-element/output.json b/test/parser/convert-entities-in-element/output.json new file mode 100644 index 0000000000..4f39e826e7 --- /dev/null +++ b/test/parser/convert-entities-in-element/output.json @@ -0,0 +1,26 @@ +{ + "html": { + "start": 0, + "end": 24, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 24, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 3, + "end": 20, + "type": "Text", + "data": "Hello & World" + } + ] + } + ] + }, + "css": null, + "js": null +} diff --git a/test/parser/convert-entities/input.html b/test/parser/convert-entities/input.html index bc5c086536..e25e3214f2 100644 --- a/test/parser/convert-entities/input.html +++ b/test/parser/convert-entities/input.html @@ -1 +1 @@ -Hello & World
+Hello & World diff --git a/test/parser/convert-entities/output.json b/test/parser/convert-entities/output.json index b086da06eb..f5124865c8 100644 --- a/test/parser/convert-entities/output.json +++ b/test/parser/convert-entities/output.json @@ -1,27 +1,17 @@ { - "hash": 1090309355, - "html": { - "start": 0, - "end": 24, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 24, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 3, - "end": 20, - "type": "Text", - "data": "Hello & World" - } - ] - } - ] - }, - "css": null, - "js": null + "html": { + "start": 0, + "end": 17, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 17, + "type": "Text", + "data": "Hello & World" + } + ] + }, + "css": null, + "js": null }