How to use the @aurelia/kernel.Metadata.define function in @aurelia/kernel

To help you get started, we’ve selected a few @aurelia/kernel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / runtime / dist / esnext / templating / children.js View on Github external
function decorator($target, $prop) {
        if (arguments.length > 1) {
            // Non invocation:
            // - @children
            // Invocation with or w/o opts:
            // - @children()
            // - @children({...opts})
            config.property = $prop;
        }
        Metadata.define(Children.name, ChildrenDefinition.create($prop, config), $target.constructor, $prop);
        Protocol.annotation.appendTo($target.constructor, Children.keyFrom($prop));
    }
    if (arguments.length > 1) {
github aurelia / aurelia / packages / runtime / src / templating / children.ts View on Github external
function decorator($target: {}, $prop: symbol | string): void {
    if (arguments.length > 1) {
      // Non invocation:
      // - @children
      // Invocation with or w/o opts:
      // - @children()
      // - @children({...opts})
      config.property = $prop as string;
    }

    Metadata.define(Children.name, ChildrenDefinition.create($prop as string, config), $target.constructor, $prop);
    Protocol.annotation.appendTo($target.constructor as Constructable, Children.keyFrom($prop as string));
  }
github aurelia / aurelia / packages / runtime / dist / esnext / templating / bindable.js View on Github external
function decorator($target, $prop) {
        if (arguments.length > 1) {
            // Non invocation:
            // - @bindable
            // Invocation with or w/o opts:
            // - @bindable()
            // - @bindable({...opts})
            config.property = $prop;
        }
        Metadata.define(Bindable.name, BindableDefinition.create($prop, config), $target.constructor, $prop);
        Protocol.annotation.appendTo($target.constructor, Bindable.keyFrom($prop));
    }
    if (arguments.length > 1) {
github aurelia / aurelia / packages / __tests__ / 1-kernel / metadata.spec.ts View on Github external
it('returns correct keys in definition order when metadata exists and redefined and without key', function () {
      const obj = {};
      Metadata.define('key1', 'value', obj, void 0);
      Metadata.define('key0', 'value', obj, void 0);
      Metadata.define('key1', 'value', obj, void 0);

      const actual = Metadata.getOwnKeys(obj, void 0);

      assert.deepStrictEqual(actual, ['key1', 'key0']);
    });
github aurelia / aurelia / packages / runtime / dist / esnext / resources / custom-element.js View on Github external
define(nameOrDef, Type) {
        const definition = CustomElementDefinition.create(nameOrDef, Type);
        Metadata.define(CustomElement.name, definition, definition.Type);
        Metadata.define(CustomElement.name, definition, definition);
        Protocol.resource.appendTo(definition.Type, CustomElement.name);
        return definition.Type;
    },
    getDefinition(Type) {
github aurelia / aurelia / packages / runtime / dist / esnext / resources / custom-element.js View on Github external
define(nameOrDef, Type) {
        const definition = CustomElementDefinition.create(nameOrDef, Type);
        Metadata.define(CustomElement.name, definition, definition.Type);
        Metadata.define(CustomElement.name, definition, definition);
        Protocol.resource.appendTo(definition.Type, CustomElement.name);
        return definition.Type;
    },
    getDefinition(Type) {
github aurelia / aurelia / packages / jit / dist / esnext / binding-command.js View on Github external
define(nameOrDef, Type) {
        const definition = BindingCommandDefinition.create(nameOrDef, Type);
        Metadata.define(BindingCommand.name, definition, definition.Type);
        Metadata.define(BindingCommand.name, definition, definition);
        Protocol.resource.appendTo(Type, BindingCommand.name);
        return definition.Type;
    },
    getDefinition(Type) {
github aurelia / aurelia / packages / runtime / dist / esnext / definitions.js View on Github external
return function (target) {
        const key = Protocol.annotation.keyFor('aliases');
        const existing = Metadata.getOwn(key, target);
        if (existing === void 0) {
            Metadata.define(key, aliases, target);
        }
        else {
            existing.push(...aliases);
        }
    };
}
github aurelia / aurelia / packages / runtime / dist / esnext / templating / view.js View on Github external
add(Type, partialDefinition) {
        const definition = CustomElementDefinition.create(partialDefinition);
        let views = Metadata.getOwn(Views.name, Type);
        if (views === void 0) {
            Metadata.define(Views.name, views = [definition], Type);
        }
        else {
            views.push(definition);
        }
        return views;
    },
};
github aurelia / aurelia / packages / jit / dist / esnext / binding-command.js View on Github external
define(nameOrDef, Type) {
        const definition = BindingCommandDefinition.create(nameOrDef, Type);
        Metadata.define(BindingCommand.name, definition, definition.Type);
        Metadata.define(BindingCommand.name, definition, definition);
        Protocol.resource.appendTo(Type, BindingCommand.name);
        return definition.Type;
    },
    getDefinition(Type) {