How to use the @aurelia/jit.PlainElementSymbol function in @aurelia/jit

To help you get started, we’ve selected a few @aurelia/jit 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 / jit-html / dist / index.es6.js View on Github external
// restore them again afterwards
        const parentManifestRootSave = this.parentManifestRoot;
        const manifestRootSave = this.manifestRoot;
        const manifestSave = this.manifest;
        // get the part name to override the name of the compiled definition
        this.partName = node.getAttribute('part');
        let manifestRoot = (void 0);
        let name = node.getAttribute('as-element');
        if (name == null) {
            name = node.nodeName.toLowerCase();
        }
        const elementInfo = this.resources.getElementInfo(name);
        if (elementInfo == null) {
            // there is no registered custom element with this name
            // @ts-ignore
            this.manifest = new PlainElementSymbol(node);
        }
        else {
            // it's a custom element so we set the manifestRoot as well (for storing replace-parts)
            this.parentManifestRoot = this.manifestRoot;
            // @ts-ignore
            manifestRoot = this.manifestRoot = this.manifest = new CustomElementSymbol(this.dom, node, elementInfo);
        }
        // lifting operations done by template controllers and replace-parts effectively unlink the nodes, so start at the bottom
        this.bindChildNodes(node);
        // the parentManifest will receive either the direct child nodes, or the template controllers / replace-parts
        // wrapping them
        this.bindAttributes(node, parentManifest);
        if (manifestRoot != null && manifestRoot.isContainerless) {
            node.parentNode.replaceChild(manifestRoot.marker, node);
        }
        else if (this.manifest.isTarget) {
github aurelia / aurelia / packages / jit-html / src / template-binder.ts View on Github external
// get the part name to override the name of the compiled definition
    this.partName = node.getAttribute('part');
    if (this.partName === '' || (this.partName === null && node.hasAttribute('replaceable'))) {
      this.partName = 'default';
    }

    let manifestRoot: CustomElementSymbol = (void 0)!;
    let name = node.getAttribute('as-element');
    if (name == null) {
      name = node.nodeName.toLowerCase();
    }
    const elementInfo = this.resources.getElementInfo(name);
    if (elementInfo == null) {
      // there is no registered custom element with this name
      // @ts-ignore
      this.manifest = new PlainElementSymbol(node);
    } else {
      // it's a custom element so we set the manifestRoot as well (for storing replace-parts)
      this.parentManifestRoot = this.manifestRoot;
      // @ts-ignore
      manifestRoot = this.manifestRoot = this.manifest = new CustomElementSymbol(this.dom, node, elementInfo);
    }

    // lifting operations done by template controllers and replace-parts effectively unlink the nodes, so start at the bottom
    this.bindChildNodes(node);

    // the parentManifest will receive either the direct child nodes, or the template controllers / replace-parts
    // wrapping them
    this.bindAttributes(node, parentManifest);

    if (manifestRoot != null && manifestRoot.isContainerless) {
      node.parentNode!.replaceChild(manifestRoot.marker as Node, node);
github aurelia / aurelia / packages / jit-html / dist / index.es6.js View on Github external
bind(node) {
        if (Tracer.enabled) {
            Tracer.enter('TemplateBinder', 'bind', slice.call(arguments));
        }
        if (Profiler.enabled) {
            enter();
        }
        const surrogateSave = this.surrogate;
        const parentManifestRootSave = this.parentManifestRoot;
        const manifestRootSave = this.manifestRoot;
        const manifestSave = this.manifest;
        const manifest = this.surrogate = this.manifest = new PlainElementSymbol(node);
        const attributes = node.attributes;
        let i = 0;
        while (i < attributes.length) {
            const attr = attributes[i];
            const attrSyntax = this.attrParser.parse(attr.name, attr.value);
            if (invalidSurrogateAttribute[attrSyntax.target] === true) {
                if (Profiler.enabled) {
                    leave();
                }
                throw new Error(`Invalid surrogate attribute: ${attrSyntax.target}`);
                // TODO: use reporter
            }
            const attrInfo = this.resources.getAttributeInfo(attrSyntax);
            if (attrInfo == null) {
                this.bindPlainAttribute(attrSyntax, attr);
            }
github aurelia / aurelia / packages / jit-html / src / template-binder.ts View on Github external
public bind(node: HTMLTemplateElement): PlainElementSymbol {
    const surrogateSave = this.surrogate;
    const parentManifestRootSave = this.parentManifestRoot;
    const manifestRootSave = this.manifestRoot;
    const manifestSave = this.manifest;
    const manifest = this.surrogate = this.manifest = new PlainElementSymbol(node);
    const resources = this.resources;
    const attrSyntaxTransformer = this.attrSyntaxTransformer;

    const attributes = node.attributes;
    let i = 0;
    while (i < attributes.length) {
      const attr = attributes[i];
      const attrSyntax = this.attrParser.parse(attr.name, attr.value);

      if (invalidSurrogateAttribute[attrSyntax.target as keyof typeof invalidSurrogateAttribute] === true) {
        throw new Error(`Invalid surrogate attribute: ${attrSyntax.target}`);
        // TODO: use reporter
      }
      const bindingCommand = resources.getBindingCommand(attrSyntax, true);
      if (bindingCommand == null || (bindingCommand.bindingType & BindingType.IgnoreCustomAttr) === 0) {
        const attrInfo = resources.getAttributeInfo(attrSyntax);