riot-js

Open full view…

opts.hasOwnProperty not a function

Josh Brown
Fri, 18 Nov 2016 19:04:31 GMT

Attempting to upgrade my solution from 2.3.18 > 2.6.7 and I am having a fair amount of heartburn with the changes that have affected the `opts` object. From what I can tell its coming down to the changes in the `inherit` method from *lib/browser/tag/uitl.js*. My issue comes down to the fact that I check for certain `opts` properties through the markup both in my tag definitions and in the `<yield></yield>` areas. In v2.6.7 it seems like in almost every case `opts` is never created in such a way that the `hasOwnProperty` method is every defined. And given that this is the best method for testing for the presence of a property on an object, im having a hard time making the transition to the latest versions. I can't be the only person having this issue. Is anyone else dealing with this or have figured out some type of workaround? See relevant library code below *version: 2.6.7, line: 400* ``` /** * Simple object prototypal inheritance * @param { Object } parent - parent object * @returns { Object } child instance */ function inherit(parent) { return Object.c reate(parent || null) } ``` *version: 2.3.18, line: 354* ``` /** * Simple object prototypal inheritance * @param { Object } parent - parent object * @returns { Object } child instance */ function inherit(parent) { function Child() {} Child.prototype = parent return new Child() } ```

simondouglas
Wed, 07 Dec 2016 00:45:21 GMT

Did you manage to get to the bottom of this? I have this problem too, and I gave up strict checking. I ended up using simple `if(this.opts.blah){}` in a try catch block. Not pretty...

simondouglas
Fri, 09 Dec 2016 00:30:01 GMT

`Object.prototype.hasOwnProperty.call(this.opts, 'YOUR_PROPERTY')` super ugly. But should work.