[fix]: strip leading newline characters after 'pre' elements

Close #7264
pull/7269/head
Emil Sandstø 5 years ago
parent 39f0d8cc31
commit 1dccec7089

1
package-lock.json generated

@ -5,6 +5,7 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "svelte",
"version": "3.46.4", "version": "3.46.4",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {

@ -197,6 +197,14 @@ export default function tag(parser: Parser) {
parser.eat('>', true); parser.eat('>', true);
// A leading newline character immediately following the pre element start tag is stripped
// See spec: https://www.w3.org/TR/2011/WD-html5-20110113/grouping-content.html#the-pre-element
if (!is_closing_tag && name === 'pre') {
if (!parser.eat('\r\n')) {
parser.eat('\n');
}
}
if (self_closing) { if (self_closing) {
// don't push self-closing elements onto the stack // don't push self-closing elements onto the stack
element.end = parser.index; element.end = parser.index;

@ -0,0 +1,25 @@
{
"html": {
"start": 0,
"end": 17,
"type": "Fragment",
"children": [
{
"start": 0,
"end": 17,
"type": "Element",
"name": "pre",
"attributes": [],
"children": [
{
"start": 6,
"end": 11,
"type": "Text",
"raw": "test\n",
"data": "test\n"
}
]
}
]
}
}
Loading…
Cancel
Save