isMdlComponent function

bool isMdlComponent (HtmlElement element, [ Type type ])

Checks if element is a "MDLComponent" type is optional - if given a stricter check is made

Implementation

bool isMdlComponent(final dom.HtmlElement element,[ final Type type ]) {
    Validate.notNull(element);
    var jsElement = new JsObject.fromBrowserObject(element);
    final bool isComponent = jsElement.hasProperty(MDL_COMPONENT_PROPERTY);

    if(isComponent && type != null) {
        return mdlComponentNames(element).contains(type.toString());
    }

    return isComponent;
}