kaleidawave / prism

(No longer in development). Experimental compiler for building isomorphic web applications with web components.
MIT License
110 stars 1 forks source link

Text interpolation reactivity throws when under un rendered element #7

Closed kaleidawave closed 4 years ago

kaleidawave commented 4 years ago

Given the following template:

<template>
    <div #if="someX">
        {someY}
    </div>
</template>

Attempting to set someY while someX is falsy will throw as the div is not rendered and thus *div*.childNodes[0].data is undefined and cannot be assigned to.

The compile is aware the element "nullable" and thus should generate code that checks can do update before trying to assign to undefined and throwing.

There is a lot of edge cases and other issues around "nullable" elements and there may be a better solution to this later but for now a patch to prevent the throw and the disruption to later execution is required