How to use the @aurelia/runtime-html.TextBindingInstruction function in @aurelia/runtime-html

To help you get started, we’ve selected a few @aurelia/runtime-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 / jit-html / dist / index.es6.js View on Github external
compileChildNodes(parent) {
        if (parent.flags & 8192 /* hasChildNodes */) {
            const { childNodes } = parent;
            let childNode;
            const ii = childNodes.length;
            for (let i = 0; i < ii; ++i) {
                childNode = childNodes[i];
                if (childNode.flags & 128 /* isText */) {
                    this.instructionRows.push([new TextBindingInstruction(childNode.interpolation)]);
                }
                else if (childNode.flags & 32 /* isLetElement */) {
                    const bindings = childNode.bindings;
                    const instructions = [];
                    let binding;
                    const jj = bindings.length;
                    for (let j = 0; j < jj; ++j) {
                        binding = bindings[j];
                        instructions[j] = new LetBindingInstruction(binding.expression, binding.target);
                    }
                    this.instructionRows.push([new LetElementInstruction(instructions, childNode.toViewModel)]);
                }
                else {
                    this.compileParentNode(childNode);
                }
            }
github aurelia / aurelia / packages / __tests__ / runtime-html / renderer.spec.ts View on Github external
describe('handles ITextBindingInstruction', function () {
    for (const from of ['${foo}', new Interpolation(['', ''], [new AccessScope('foo')])] as any[]) {
      const instruction = new TextBindingInstruction(from) as any;
      it(_`instruction=${instruction}`, function () {
        const { ctx, sut, dom, renderable, target, placeholder, wrapper, renderContext } = setup();

        sut.instructionRenderers[instruction.type].render(LF.none, dom, renderContext, renderable, target, instruction);

        expect(renderable.$componentHead).to.equal(null);
        expect(renderable.$componentTail).to.equal(null);
        expect(renderable.$bindingHead).to.be.a('object', 'renderable.$componentHead');
        expect(renderable.$bindingHead).to.equal(renderable.$bindingTail);
        const bindable = renderable.$bindingHead as InterpolationBinding;
        expect(bindable.target).to.equal(placeholder);
        expect(bindable.interpolation['expressions'][0]['name']).to.equal('foo');
        expect(bindable.interpolation['parts'][0]).to.equal('');
        expect(bindable.interpolation['parts'][1]).to.equal('');
        expect(bindable.mode).to.equal(BindingMode.toView);
        //expect(target.isConnected).to.equal(false);
github aurelia / aurelia / test / kitchen-sink / src / app.ts View on Github external
strategy |= BindingStrategy.proxies;
    }
    const dom = this.$controller.context.get>(IDOM);
    this.subject = createElement(
      dom,
      'table',
      {
        class: 'table is-fullwidth',
      },
      [
        createElement(dom, 'thead', {}, [
          createElement(dom, 'tr', {
            $1: new HydrateTemplateController({
              name: '',
              template: ' ',
              instructions: [[new TextBindingInstruction(`\${col | pascal}`)]],
              strategy
            },
            'repeat',
            [new IteratorBindingInstruction(this.keyedStrategy ? 'col of cols' : 'col of cols', 'items')]
            )
          })
        ]),
        createElement(dom, 'tbody', {
          $1: new HydrateTemplateController({
            name: '',
            template: '',
            instructions: [[new HydrateTemplateController({
              name: '',
              template: ' ',
              instructions: [[new TextBindingInstruction(`\${row[col]}`)]],
              strategy
github aurelia / aurelia / packages / __tests__ / 2-runtime / controller.spec.ts View on Github external
} = setup();

      const flags = LF.none;

      const ViewModel = createViewModel(
        h(
          'div',
          null,
          h('au-m', { class: 'au' }),
          '',
          h('au-m', { class: 'au' }),
        ),
        [],
        [
          [
            new TextBindingInstruction(parseExpression(`\${id&oneTime}`, BindingType.Interpolation)),
          ],
          [
            new HydrateTemplateController(
              createDescription(
                'if',
                h('view-model', { class: 'au' }),
                [],
                [
                  [new HydrateElementInstruction('view-model', [])],
                ],
                noHooks,
              ),
              'if',
              [new ToViewBindingInstruction(parseExpression('id===1&oneTime'), 'value')],
            ),
          ],
github aurelia / aurelia / packages / jit-html / src / template-compiler.ts View on Github external
private compileChildNodes(parent: IElementSymbol): void {
    if (parent.flags & SymbolFlags.hasChildNodes) {
      const { childNodes } = parent;
      let childNode: INodeSymbol;
      const ii = childNodes.length;
      for (let i = 0; i < ii; ++i) {
        childNode = childNodes[i];
        if (childNode.flags & SymbolFlags.isText) {
          this.instructionRows.push([new TextBindingInstruction((childNode as TextSymbol).interpolation)]);
        } else if (childNode.flags & SymbolFlags.isLetElement) {
          const bindings = (childNode as LetElementSymbol).bindings;
          const instructions: ILetBindingInstruction[] = [];
          let binding: BindingSymbol;
          const jj = bindings.length;
          for (let j = 0; j < jj; ++j) {
            binding = bindings[j];
            instructions[j] = new LetBindingInstruction(binding.expression as IsBindingBehavior, binding.target);
          }
          this.instructionRows.push([new LetElementInstruction(instructions, (childNode as LetElementSymbol).toViewModel)]);
        } else {
          this.compileParentNode(childNode as IParentNodeSymbol);
        }
      }
    }
  }
github aurelia / aurelia / packages / jit-html / src / template-compiler.ts View on Github external
private compileChildNodes(parent: IElementSymbol): void {
    if (parent.flags & SymbolFlags.hasChildNodes) {
      const { childNodes } = parent;
      let childNode: INodeSymbol;
      const ii = childNodes.length;
      for (let i = 0; i < ii; ++i) {
        childNode = childNodes[i];
        if (childNode.flags & SymbolFlags.isText) {
          this.instructionRows.push([new TextBindingInstruction((childNode as TextSymbol).interpolation)]);
        } else if (childNode.flags & SymbolFlags.isLetElement) {
          const bindings = (childNode as LetElementSymbol).bindings;
          const instructions: ILetBindingInstruction[] = [];
          let binding: BindingSymbol;
          const jj = bindings.length;
          for (let j = 0; j < jj; ++j) {
            binding = bindings[j];
            instructions[j] = new LetBindingInstruction(binding.expression as IsBindingBehavior, binding.target);
          }
          this.instructionRows.push([new LetElementInstruction(instructions, (childNode as LetElementSymbol).toViewModel)]);
        } else {
          this.compileParentNode(childNode as IParentNodeSymbol);
        }
      }
    }
  }