define method

void define(
  1. String name,
  2. CustomElementConstructor constructor, [
  3. List<String> attributes = const <String>[]
])

Implementation

void define(
  String name,
  CustomElementConstructor constructor, [
  List<String> attributes = const <String>[],
]) {
  final count = attributes.length;
  final jsAttributes = JSArray<JSString>.withLength(count);
  for (var i = 0; i < count; ++i) {
    jsAttributes[i] = attributes[i].toJS;
  }

  JSBoxedDartObject construct(js.HTMLElement jsObject) =>
      constructor(jsObject).toJSBox;

  jsObject.define(name, construct.toJS, jsAttributes);
}