yapplabs / ember-strong-attrs

Declare and enforce your Ember Component's attributes and their types
MIT License
38 stars 3 forks source link

Fix attrs check not working #11

Closed jnhuynh closed 9 years ago

jnhuynh commented 9 years ago

@lukemelia this one is a bit of a doozy. I previous change this.constructor.superclass[declaredStrongAttrsKey] to this.constructor[declaredStrongAttrsKey] because my unit tests were failing.

It turns out that where the declaredStrongAttrsKey lives, depends on how the component is instantiated.

My unit tests were instantiating them as if they were regular JS objects (e.g. Component.create. This created an instance whose constructor property was an Ember component subclass, which is what we would expect.

However, when components are instantiated via an HBS, a function is somehow inserted in between. It was a function (appname@components:component-name, whose superclass property is the Ember component subclass that we wanted. I suspect it's an Ember CLI module thingy.

Anyway, I've made the fix and rewrote all of the unit tests to be integration tests. I've also made jshint happy by telling it to ignore parts of our code. This would tie in nicely with: https://github.com/yapplabs/ember-strong-attrs/issues/4

lukemelia commented 9 years ago

This feel a little whack-a-mole, but an improvement from where we were at. I will try to get someone who understand the inheritance model really well to take a look, like @krisselden.