Precise DOM morphing
morphing typescript dom

Remove type casting

+3 -4
+1 -1
dist/morphlex.js
··· 72 72 if (elem.value !== guide.value) 73 73 elem.value = guide.value; 74 74 const text = elem.firstChild; 75 - if (text && text.textContent !== guide.value) 75 + if (text && isText(text) && text.textContent !== guide.value) 76 76 text.textContent = guide.value; 77 77 } 78 78 }
+2 -3
src/morphlex.ts
··· 75 75 else if (isTextArea(elem) && isTextArea(guide)) { 76 76 if (elem.value !== guide.value) elem.value = guide.value; 77 77 78 - // TextAreas only have one child node and it’s always a text node, so we can safely cast here. 79 - const text = elem.firstChild as Text | null; 80 - if (text && text.textContent !== guide.value) text.textContent = guide.value; 78 + const text = elem.firstChild; 79 + if (text && isText(text) && text.textContent !== guide.value) text.textContent = guide.value; 81 80 } 82 81 } 83 82