use decodeCharacterReferences in text.js, not tag.js

pull/103/head
Rich-Harris 8 years ago
parent 84c9f647dd
commit 90fac61d2a

@ -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();
}
}

@ -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;

@ -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
}

@ -1 +1 @@
<p>Hello &amp; World</p>
Hello &amp; World

@ -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
}

Loading…
Cancel
Save