nanomorph-guard
Guard element against being touched by nanomorph
Requires nanomorph@5.4.0 or up.
Usage
Useful with components that expect to keep a reference to their parent element,
but that you still would like to use in combination with nanomorph
Below is an example that manually updates a text node every second, while
only morphing the DOM every five seconds. The reference to manualElm
is not
lost.
var guard = var morph = var html = var manualElm = documentvar text = documentmanualElm { } { texttextContent = `Updated by manually on `}
API
var el = guard(element)
Protect element
from being morphed by nanomorph
. Will return element
itself if not a Node
, eg. string
, DocumentFragment
, array
or other types
that you may sometimes pass to nanohtml
/nanomorph
Install
npm install nanomorph-guard