tinymins / vue-transfer-dom.js

A directive supported plugin for transfering DOM to another location in Vue.js components.
https://www.npmjs.com/package/vue-transfer-dom.js
1 stars 1 forks source link

Support for .replace modifier #1

Closed emahuni closed 5 years ago

emahuni commented 5 years ago

I think package is wonderful, simpler than portal-vue. Question is can't it replace the content of target also much like the prepend modifier?

something like the following:

<div v-transfer-dom:footer.replace>thing that should be transferred</div>
tinymins commented 5 years ago

Thanks for your advice! https://github.com/tinymins/vue-transfer-dom.js/commit/fafeb7e9dc22af4cc062fce5ee29b05f8e2e6d54

emahuni commented 5 years ago

Your implementation of the replace modifier behaviour is ok, however, when I suggested this I was of the impression that it would clear the contents of the target then become its only child instead of destroying the target. I think we can call this new feature i just mentioned here clear so that it is different in a sense and leave replace doing what you just made it do. It could do it this way; in fact I had implemented virtually all of this functionality. Just having a few bugs here and there (in the remove function) so it could just do this:

let child;
while((child = parentNode.firstChild)) {
child.remove()
}

before it becomes the only child.

emahuni commented 5 years ago

so opening a new feature request