How to use the @glimmer/util.unwrap function in @glimmer/util

To help you get started, we’ve selected a few @glimmer/util 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 glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / compat / svg-inner-html-fix.ts View on Github external
function shouldApplyFix(document: Document, svgNamespace: SVG_NAMESPACE) {
  let svg = document.createElementNS(svgNamespace, 'svg');

  try {
    svg['insertAdjacentHTML']('beforeend', '');
  } catch (e) {
    // IE, Edge: Will throw, insertAdjacentHTML is unsupported on SVG
    // Safari: Will throw, insertAdjacentHTML is not present on SVG
  } finally {
    // FF: Old versions will create a node in the wrong namespace
    if (svg.childNodes.length === 1 && unwrap(svg.firstChild).namespaceURI === SVG_NAMESPACE) {
      // The test worked as expected, no fix required
      return false;
    }

    return true;
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / suites / initial-render.ts View on Github external
this.assert.equal(selectNode.selectedIndex, 0);

    this.assertStableNodes();

    this.rerender({ selected: '' });

    this.assertHTML(strip`
      <select>
        <option>1</option>
        <option selected="true'">2</option>
        <option>3</option>
      </select>
    `);

    selectNode = unwrap(firstElementChild(this.element)) as HTMLSelectElement;

    this.assert.equal(selectNode.selectedIndex, 0);

    this.assertStableNodes();

    this.rerender({ selected: true });
    this.assertHTML(strip`
      <select>
        <option>1</option>
        <option selected="true'">2</option>
        <option>3</option>
      </select>
    `);

    selectNode = unwrap(firstElementChild(this.element)) as HTMLSelectElement;
    this.assert.equal(selectNode.selectedIndex, 1);
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax.ts View on Github external
builder.startLabels();

    builder.pushFrame();

    builder.returnTo('END');

    expr(params[0], builder);

    builder.toBoolean();

    builder.enter(1);

    builder.jumpUnless('ELSE');

    builder.invokeStaticBlock(unwrap(template));

    if (inverse) {
      builder.jump('EXIT');

      builder.label('ELSE');
      builder.invokeStaticBlock(inverse);

      builder.label('EXIT');
      builder.exit();
      builder.return();
    } else {
      builder.label('ELSE');
      builder.exit();
      builder.return();
    }
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / syntax / functions.ts View on Github external
builder.jumpUnless('ELSE');

    builder.pushFrame();

    builder.returnTo('ITER');

    builder.dup(Register.fp, 1);

    builder.enterList('BODY');

    builder.label('ITER');
    builder.iterate('BREAK');

    builder.label('BODY');
    builder.invokeStatic(unwrap(template), 2);
    builder.pop(2);
    builder.exit();
    builder.return();

    builder.label('BREAK');
    builder.exitList();
    builder.popFrame();

    if (inverse) {
      builder.jump('EXIT');

      builder.label('ELSE');
      builder.invokeStatic(inverse);

      builder.label('EXIT');
      builder.exit();
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax.ts View on Github external
builder.putIterator();

        builder.jumpUnless('ELSE');

        builder.pushFrame();

        builder.dup(Register.fp, 1);

        builder.returnTo('ITER');
        builder.enterList('BODY');

        builder.label('ITER');
        builder.iterate('BREAK');

        builder.label('BODY');
        builder.invokeStaticBlock(unwrap(template), 2);
        builder.pop(2);
        builder.jump('FINALLY');

        builder.label('BREAK');
        builder.exitList();
        builder.popFrame();

        builder.jump('FINALLY');
        builder.label('ELSE');

        if (inverse) {
          builder.invokeStaticBlock(inverse);
        }
      },
    });
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / syntax / functions.ts View on Github external
invoke(vm: VM, _partial: Option) {
    let partial = unwrap(_partial);
    let partialSymbols = partial.symbolTable.symbols;
    let outerScope = vm.scope();
    let partialScope = vm.pushRootScope(partialSymbols.length, false);
    partialScope.bindCallerScope(outerScope.getCallerScope());
    partialScope.bindEvalScope(outerScope.getEvalScope());
    partialScope.bindSelf(outerScope.getSelf());

    let { evalInfo, outerSymbols } = this;

    let locals = dict&gt;();

    evalInfo.forEach(slot =&gt; {
      let name = outerSymbols[slot - 1];
      let ref  = outerScope.getSymbol(slot);
      locals[name] = ref;
    });
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax / builtins.ts View on Github external
ifTrue() {
        return invokeStaticBlockWithStack(unwrap(blocks.get('default')), 1);
      },