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

Update README.md #4

Closed emahuni closed 5 years ago

emahuni commented 5 years ago

fix: typos and gramma

emahuni commented 5 years ago

There are a few things that are note clear here...

This example:

<div v-transfer-dom:header.replace>This <div> will replace the node with the `header` id, wherever it is in the DOM</div>

is not using the target param, but yet you said:

Please note that this modifier will only be valid when used with target param.

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.

classes and multiple elements

You need to make clones of source node should there be multiple nodes that result from the queryselect.

tinymins commented 5 years ago

Yeah, seems that it is a mistake of saying modifier will only be valid when used with target param, since target field can be set from not only params but also from modifier.

<div v-transfer-dom:header.replace> equals with <div v-transfer-dom.replace="{ target: '#header' }">

emahuni commented 5 years ago

ok, so we can remove that limitation notice then?

tinymins commented 5 years ago

In fact, that may be dangerous. Because if you do not set target, the default target will be body, which means it will remove whole body with this transfer-dom.