How to use the @aurelia/jit-html.TemplateBinder function in @aurelia/jit-html

To help you get started, we’ve selected a few @aurelia/jit-html 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 / __tests__ / 5-jit-html / has-multi-bindings.unit.spec.ts View on Github external
it(markup, function () {
      const ctx = TestContext.createHTMLTestContext();
      const { dom, container } = ctx;

      container.register(CustomAttribute.define({ name: 'attr', bindables: ['a', 'b', 'c'] }, class {}));

      const resources = new ResourceModel(container);

      const attrParser = container.get(IAttributeParser);
      const exprParser = container.get(IExpressionParser);
      const transformer = container.get(IAttrSyntaxTransformer);
      const factory = container.get(ITemplateElementFactory);

      const sut = new TemplateBinder(dom, resources, attrParser, exprParser, transformer);

      const template = factory.createTemplate(markup) as HTMLTemplateElement;
      const manifestRoot = sut.bind(template);
      const div = manifestRoot.childNodes[0] as PlainElementSymbol;

      const { customAttributes } = div;
      assert.strictEqual(customAttributes.length, 1, 'customAttributes.length');

      const [{ bindings }] = customAttributes;
      assert.strictEqual(bindings.length, expectedBindings.length, 'bindings.length');

      for (const expectedBinding of expectedBindings) {
        const binding = bindings.find(b => b.target === expectedBinding.target && b.rawValue === expectedBinding.rawValue);
        assert.notStrictEqual(binding, void 0, `${JSON.stringify(bindings.map(({ target, rawValue }) => ({ target, rawValue })))}.find(b => b.target === ${expectedBinding.target} && b.rawValue === ${expectedBinding.rawValue})`);
      }
    });
github aurelia / aurelia / packages / __tests__ / jit-html / kitchen-sink.spec.ts View on Github external
it.skip(escaped, function () {
      const ctx = TestContext.createHTMLTestContext();
      const parser = new ctx.DOMParser();
      const doc = parser.parseFromString(markup, 'application/xml');
      const fakeSurrogate = { firstChild: doc, attributes: [] };

      const binder = new TemplateBinder(
        ctx.dom,
        new ResourceModel(new RuntimeCompilationResources(ctx.container)),
        ctx.container.get(IAttributeParser),
        ctx.container.get(IExpressionParser),
        ctx.container.get(IAttrSyntaxTransformer)
      );

      const result = binder.bind(fakeSurrogate as any);
      assert.strictEqual(result.physicalNode, fakeSurrogate, `result.physicalNode`);
    });
  }

@aurelia/jit-html

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/) [![TypeScript](https://img.shields.io/badge/%3C%2F

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis