-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
18 lines (15 loc) · 680 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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;
}
}];