enode.ref()
Method enode.ref() is used to associate the current enode with another targeted enode.
As the result, both enodes will associate with the same HTML element (from the targeted enode), and whenever any one of them changes the associated HTML element, the other will also change its associated HTML element to that HTML element. This also works for multiple enodes, not only two. However, it only works properly if changing the associated HTML element using enode.set() or enode.swap().
Syntax
JavaScript
enode.ref(enodeTarget: Binh.ElementNode)
Parameters
enodeTarget
- Expect an enode generated by
Binh.ElementNode.
Return value
The current enode with a new associated HTML element from enodeTarget.
Examples
JavaScript
var content = new Binh.ElementNode(document.createElement('div'));
var text = new Binh.ElementNode(document.createElement('span'));
var link = new Binh.ElementNode(document.createElement('a'));
console.log(content.element); // Output: <div></div>
console.log(text.element); // Output: <span></span>
console.log(link.element); // Output: <a></a>
content.ref(text);
console.log(content.element); // Output: <span></span>
console.log(text.element); // Output: <span></span>
console.log(link.element); // Output: <a></a>
text.ref(link);
console.log(content.element); // Output: <a></a>
console.log(text.element); // Output: <a></a>
console.log(link.element); // Output: <a></a>