mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-10-29 16:43:33 +03:00
15 lines
703 B
JavaScript
15 lines
703 B
JavaScript
ko.bindingHandlers['text'] = {
|
|
'init': () => (
|
|
// Prevent binding on the dynamically-injected text node (as developers are unlikely to expect that, and it has security implications).
|
|
// It should also make things faster, as we no longer have to consider whether the text node might be bindable.
|
|
{ 'controlsDescendantBindings': true }
|
|
),
|
|
'update': (element, valueAccessor) => {
|
|
if (8 === element.nodeType) {
|
|
element.text || element.after(element.text = document.createTextNode(''));
|
|
element = element.text;
|
|
}
|
|
ko.utils.setTextContent(element, valueAccessor());
|
|
}
|
|
};
|
|
ko.virtualElements.allowedBindings['text'] = true;
|