Skip to content

fixed replaceChild bug#229

Open
Gcaufy wants to merge 1 commit intojindw:masterfrom
Gcaufy:patch-1
Open

fixed replaceChild bug#229
Gcaufy wants to merge 1 commit intojindw:masterfrom
Gcaufy:patch-1

Conversation

@Gcaufy
Copy link

@Gcaufy Gcaufy commented Jan 24, 2018

// node: <div><slot /></div>
// newChild: Hello World
// oldChild: <slot />

node.replaceChild(newChild, oldChild);

// Expect: <div>Hello World</div>
// Actually: Hello World

But if I added a space befor <slot />, I get the correct result.

// node: <div> <slot /></div>
// newChild: Hello World
// oldChild: <slot />

node.replaceChild(newChild, oldChild);

// Expect: <div> Hello World</div>
// Actually: <div> Hello World</div>

Copy link

@songkeys songkeys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It keeps reporting:

TypeError: Cannot read property 'parentNode' of null

Should be:

if (nextChild != null) {
	nextChild.parentNode.firstChild = newFirst;
}else{
	parentNode.firstChild = newFirst;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants