cdig / svga

A framework for making interactive animations with SVG.
https://github.com/cdig/svga/wiki
MIT License
8 stars 2 forks source link

Bad scope references don't error properly due to DOM elements on window #138

Closed ivanreese closed 7 years ago

ivanreese commented 8 years ago

Let's say we have an SVG with an element/scope named aLine. In the parent scope, we can say @aLine to refer to this scope.

But if we say aLine without the @, we end up referring to a reference to the DOM element that was added to the window object. I believe the browser does this automatically, because the element has id="aLine".

The problem is.. if someone types aLine.pressure = 5, it won't throw an error. It should, because they meant to type @aLine.pressure = 5 and forgot the @.

So we need to find a way to scrub all these element references off the window, so that if you say aLine.pressure you get an error.

We can say window.aLine = null and that will work. But — better — we should overwrite the window element references with our own custom objects, so we can throw a nice error like You typed aLine when you probably meant to type @aLine