Check if a variable is an enyo instance

edited April 2014 in Enyo 2
Hi,

Is there a way to check if an object is an enyo instance (or a component of an enyo instance)?

Because checking if the object is an instance of enyo.instance doesn't always work. See for yourself:
enyo.kind({
name: "Test"
components: [
{name: "test", content: "yo"}
]
})

var x = new Test();
x instanceof enyo.instance // true
x.$.test instanceof enyo.instance //
But in both case the __proto__ property is an instance of enyo.instance. Is it a safe check?

Comments

  • instanceof enyo.Object works in almost all cases except when kinds are explicitly derived from "null" (like Model, Source, Binding, and Layout).
  • edited April 2014
    PS: I failed my edit of the original post, the second check (last line of code) is false

    I actually wanted to check if an object was an instance of enyo.Control (or a class that inherits from enyo.Control), so this is perfect. Thank you !
Sign In or Register to comment.