A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue/commit/e02fb1294d1084d6f2224cf93a1425b09b1d8b5c below:

preserve the only whitespace child (#4760) · vuejs/vue@e02fb12 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+7

-3

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+7

-3

lines changed Original file line number Diff line number Diff line change

@@ -197,7 +197,7 @@ export function parse (

197 197

// remove trailing whitespace

198 198

const element = stack[stack.length - 1]

199 199

const lastNode = element.children[element.children.length - 1]

200 -

if (lastNode && lastNode.type === 3 && lastNode.text === ' ') {

200 +

if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {

201 201

element.children.pop()

202 202

}

203 203

// pop stack

@@ -242,7 +242,7 @@ export function parse (

242 242

expression,

243 243

text

244 244

})

245 -

} else if (text !== ' ' || children[children.length - 1].text !== ' ') {

245 +

} else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {

246 246

currentParent.children.push({

247 247

type: 3,

248 248

text

Original file line number Diff line number Diff line change

@@ -481,12 +481,16 @@ describe('parser', () => {

481 481 482 482

it('preserve whitespace in <pre> tag', function () {

483 483

const options = extend({}, baseOptions)

484 -

const ast = parse('<pre><code> \n<span>hi</span>\n </code></pre>', options)

484 +

const ast = parse('<pre><code> \n<span>hi</span>\n </code><span> </span></pre>', options)

485 485

const code = ast.children[0]

486 486

expect(code.children[0].type).toBe(3)

487 487

expect(code.children[0].text).toBe(' \n')

488 488

expect(code.children[2].type).toBe(3)

489 489

expect(code.children[2].text).toBe('\n ')

490 + 491 +

const span = ast.children[1]

492 +

expect(span.children[0].type).toBe(3)

493 +

expect(span.children[0].text).toBe(' ')

490 494

})

491 495 492 496

it('forgivingly handle < in plain text', () => {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4