samedi 25 février 2017

Does JavaScript in the browser have a reflection mechanism?

I would like to get a list of all the properties, styles, events and methods of an HTML element. Is there a reflection API in the browsers?

I'm looking for something like this:

var button = new HTMLButtonElement();
var className = document.getQualifiedClassName(button); // "HTMLButtonElement"
var definition = document.getDefinition(className); // HTMLButtonElement reference
var instance = document.getInstance(definition); // instance of HTMLButtonElement
var properties = document.getProperties(button); // properties of HTMLButtonElement
var methods = document.getMethods(button); // methods of HTMLButtonElement
var styles = document.getStyles(button); // styles applicable to HTMLButtonElement
var events = document.getEvents(button); // events on HTMLButtonElement
var inheritance = document.getInheritance(button); // HTMLButtonElement > HTMLElement

This is the call in ActionScript3 that gets what I'm looking for:

var objectInformation = document.describeType(button) // metadata

This may make it more clear what I'm trying to do in JavaScript.

Aucun commentaire:

Enregistrer un commentaire