enode.set()
Method enode.set() is used to change the HTML element associated with the current enode.
Using this method will change the value of enode.element, but not affect the previous HTML element if already rendered on DOM.
tip
In case of expecting changes reflected on DOM when assigning a new HTML element to an enode, use enode.swap().
Syntax
JavaScript
enode.set(element: HTMLElement)
Parameters
element
- A HTML element to be associated with the current enode.
- Expect native HTML objects like Node, Element, and DocumentFragment.
Return value
The current enode with a new associated HTML element.
Examples
JavaScript
var div = new Binh.ElementNode(document.createElement('div'));
var spanEl = document.createElement('span');
console.log(div.element);
// Output: <div></div>
div.set(spanEl);
console.log(div.element);
// Output: <span></span>
div.set();
console.log(div.element);
// Output: undefined