Reflect properties into DOM attributes, it's faster

This commit is contained in:
nathan 2021-12-21 11:16:58 -07:00
parent 5bdf12f1b9
commit 0f45aed876
2 changed files with 12 additions and 5 deletions

View File

@ -50,20 +50,23 @@ export class Et2Description extends Et2Widget(LitElement) implements et2_IDetach
* Goes with href. If provided, that's the target for opening the link. * Goes with href. If provided, that's the target for opening the link.
*/ */
extra_link_target: { extra_link_target: {
type: String type: String,
reflect: true
}, },
/** /**
* widthxheight, if popup should be used, eg. 640x480 * widthxheight, if popup should be used, eg. 640x480
*/ */
extra_link_popup: { extra_link_popup: {
type: String type: String,
reflect: true
}, },
/** /**
* Link URL * Link URL
* If provided, will be clickable and open this URL * If provided, will be clickable and open this URL
*/ */
href: { href: {
type: String type: String,
reflect: true
}, },
value: String, value: String,
} }

View File

@ -178,15 +178,19 @@ export class et2_nextmatch_rowProvider
data[set.attribute] = mgrs["content"].expandName(set.expression); data[set.attribute] = mgrs["content"].expandName(set.expression);
} }
// WebComponent IS the node, and we've already cloned it // WebComponent IS the node, and we've already cloned it
// N.B. it's missing its unreflected (internal) properties
if(typeof window.customElements.get(widget.localName) != "undefined") if(typeof window.customElements.get(widget.localName) != "undefined")
{ {
// Use the clone, not the original /*
// N.B. cloneNode widget is missing its unreflected properties and we need to use widget.clone()
// instead to get them. This slows things down.
let c = widget.clone(); let c = widget.clone();
let partial = entry.nodeFuncs[0](row); let partial = entry.nodeFuncs[0](row);
partial.parentNode.insertBefore(c, partial); partial.parentNode.insertBefore(c, partial);
partial.parentNode.removeChild(partial); partial.parentNode.removeChild(partial);
widget = c; widget = c;
*/
// Use the clone, not the original
widget = entry.nodeFuncs[0](row);
} }
else else
{ {