mirror of
https://github.com/archtechx/wire-replace.git
synced 2025-12-12 07:34:02 +00:00
Initial commit
This commit is contained in:
commit
edbfe280eb
8 changed files with 181 additions and 0 deletions
18
index.js
Normal file
18
index.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Add wire:replace functionality to Livewire.
|
||||
*
|
||||
* When wire:replace is applied to an element, the element's children will *always* be fully replaced rather than intelligently DOM-diffed.
|
||||
* When wire:replace.self is applied to an element, the element itself (plus all of its children) will be
|
||||
*/
|
||||
|
||||
export default ['element.updating', (from, to) => {
|
||||
let attributes = Object.values(from.attributes);
|
||||
|
||||
if (attributes.filter(attribute => attribute.name === 'wire:replace').length) {
|
||||
from.innerHTML = to.innerHTML;
|
||||
}
|
||||
|
||||
if (attributes.filter(attribute => attribute.name === 'wire:replace.self').length) {
|
||||
from.outerHTML = to.outerHTML;
|
||||
}
|
||||
}];
|
||||
Loading…
Add table
Add a link
Reference in a new issue