Skip to content

Missing returns for Node.{insertBefore, appendChild, replaceChild, removeChild}#15

Merged
developit merged 3 commits intodevelopit:masterfrom
andyrj:master
Jan 22, 2018
Merged

Missing returns for Node.{insertBefore, appendChild, replaceChild, removeChild}#15
developit merged 3 commits intodevelopit:masterfrom
andyrj:master

Conversation

@andyrj
Copy link
Contributor

@andyrj andyrj commented Oct 2, 2017

To match actual dom api these calls need to return the nodes added or removed.

https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore
https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild
https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
https://developer.mozilla.org/en-US/docs/Web/API/Node/replaceChild

Was there a reason for leaving off these returns? Ran into this using undom with hyperapp.

@andyrj andyrj changed the title Node.insertBefore should return insertedNode Missing returns for Node.{insertBefore, appendChild, replaceChild, removeChild} Oct 2, 2017
child.parentNode = this;
if (!ref) this.childNodes.push(child);
else splice(this.childNodes, ref, child);
!ref ? this.childNodes.push(child) : splice(this.childNodes, ref, child);
Copy link
Owner

Choose a reason for hiding this comment

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

I think this is pretty much what Uglify does (haven't checked).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eslint complained when I simply added return after the if/else as it thought the return was only for the else case. So I switched to the ternary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not that changing simply because eslint says so is the right thing, but in this case it does seem to make things clearer with the ternary imo.

@zaceno
Copy link

zaceno commented Oct 10, 2017

Bump! I'd love to see this merged and released soon!

@andyrj
Copy link
Contributor Author

andyrj commented Nov 2, 2017

@developit Is there any chance this will be merged? I'd prefer to avoid publishing a fork to npm just for these return statements. 😞

@developit
Copy link
Owner

Sorry about the super slow response! I'm merging.

@developit developit merged commit 92c9808 into developit:master Jan 22, 2018
@zaceno
Copy link

zaceno commented Jan 22, 2018

Thanks @developit !! 🎉

@andyrj
Copy link
Contributor Author

andyrj commented Jan 22, 2018

@developit Thank you!

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.

3 participants