当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TestEnvironment.begin方法代码示例

本文整理汇总了TypeScript中glimmer-test-helpers.TestEnvironment.begin方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TestEnvironment.begin方法的具体用法?TypeScript TestEnvironment.begin怎么用?TypeScript TestEnvironment.begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在glimmer-test-helpers.TestEnvironment的用法示例。


在下文中一共展示了TestEnvironment.begin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

window['$BENCH'].render = function() {
  let { env, context, template, TestDynamicScope } = this;
  let frag = document.createDocumentFragment();
  env.begin();
  template.render(context, env, { appendTo: frag, dynamicScope: new TestDynamicScope(null) });
  env.commit();
  return frag;
};
开发者ID:GCheung55,项目名称:glimmer,代码行数:8,代码来源:bench-inline.ts

示例2: test

test("HTML tags re-rendered", function() {
  let template = compile("<h1>hello!</h1><div>content</div>");
  let result = render(template, {});

  let oldFirstChild = root.firstChild;

  env.begin();
  result.rerender();
  env.commit();

  strictEqual(root.firstChild, oldFirstChild);
  equalTokens(root, "<h1>hello!</h1><div>content</div>");
});
开发者ID:Joelkang,项目名称:glimmer,代码行数:13,代码来源:initial-render-test.ts

示例3: rerender

function rerender(context: Object = {}, params: RerenderParams = { assertStable: false }) {
  let snapshot;
  if (params.assertStable) {
    snapshot = generateSnapshot(root);
  }
  self.update(opaque(context));
  env.begin();
  result.rerender();
  env.commit();
  if (params.assertStable) {
    equalSnapshots(generateSnapshot(root), snapshot);
  }
}
开发者ID:byelipk,项目名称:glimmer,代码行数:13,代码来源:partial-test.ts

示例4: rerender

function rerender(context: any = null) {
  if (context !== null) self.update(context);
  env.begin();
  result.rerender();
  env.commit();
}
开发者ID:Radascript,项目名称:glimmer,代码行数:6,代码来源:attributes-test.ts

示例5: renderContent

function renderContent() {
  let data = JSON.parse($data.value);

  let env = new TestEnvironment();

  env.registerEmberishGlimmerComponent("h-card", null, $layout.value);

  let app = env.compile($template.value);

  function compileLayout(component) {
    let definition = env.getComponentDefinition([component]);
    let compiled = layoutFor(definition, env);
    let children = definition['compileLayout'](env).children;

    // Fake a Block
    return { compiled, children, compile() {} };
  }

  function compileInner(block) {
    block.compile(env);
    block.children.forEach(compileInner);
  }

  function processOpcodes(block) {
    compileInner(block);

    return {
      opcodes: block.compiled.ops.toArray().map(op => op.toJSON()),
      children: block.children.map(processOpcodes)
    };
  }

  function processUpdatingOpcodes(list) {
    return res['updating'].toArray().map(op => op.toJSON());
  }

  let div = document.createElement('div');

  env.begin();
  let self = new UpdatableReference(data);
  let res = app.render(self, env, { appendTo: div, dynamicScope: new TestDynamicScope(null) });
  env.commit();

  ui.rendered = true;

  ui.template.source = $template.value;
  ui.template.wireFormat = JSON.parse(compileSpec($template.value, {}));
  ui.template.opcodes = processOpcodes(app.raw);

  ui.layout.source = $layout.value;
  ui.layout.wireFormat = JSON.parse(compileSpec($layout.value, {}));
  ui.layout.opcodes = processOpcodes(compileLayout("h-card"));

  ui.updatingOpcodes = processUpdatingOpcodes(res['updating']);

  ui.html = div.innerHTML;

  window['$UI'] = ui;
  window['$DIV'] = div;

  _updateContent = () => {
    self.update(JSON.parse($data.value));
    res.rerender();
    ui.updatingOpcodes = processUpdatingOpcodes(res['updating']);
    ui.html = div.innerHTML;
    rerenderUI();
  };

  rerenderUI();
}
开发者ID:GCheung55,项目名称:glimmer,代码行数:70,代码来源:visualizer.ts

示例6: renderUI


//.........这里部分代码省略.........
        <li><span class="pre">{{json local}}</span></li>
      {{/each}}
    </ol>
    <hr />
  {{/if}}
  {{#if @spec.named}}
    <h3>Named</h3>
    <ol>
      {{#each @spec.named key="@index" as |name|}}
        <li><span class="pre">{{json name}}</span></li>
      {{/each}}
    </ol>
    <hr />
  {{/if}}
  {{#if @spec.yields}}
    <h3>Yields</h3>
    <ol>
      {{#each @spec.yields key="@index" as |yield|}}
        <li><span class="pre">{{json yield}}</span></li>
      {{/each}}
    </ol>
    <hr />
  {{/if}}
  {{#if @spec.blocks}}
    <h3>Blocks</h3>
    <ol>
      {{#each @spec.blocks key="@index" as |block|}}
        <li>
          <h3>Block</h3>
          {{wire-format-inspector spec=block}}
        </li>
      {{/each}}
    </ol>
  {{/if}}
</div>`);

  env.registerHelper("pp-opcode", ([opcode]) => {
    let output = opcode.type.toUpperCase();

    if (opcode.args || opcode.details) {
      output += "(";

      if (opcode.args && opcode.args.length) {
        output += opcode.args.join(", ");
      }

      if (opcode.details) {
        let keys = Object.keys(opcode.details);

        if (keys.length) {
          if (opcode.args && opcode.args.length) {
            output += ", ";
          }

          output += keys.map(key => `${key}=${opcode.details[key]}`).join(", ");;
        }
      }

      output += ")";
    }

    return output;
  });

  env.registerEmberishGlimmerComponent("opcode-inspector", null,
`<li>
  <span class="pre">{{pp-opcode @opcode}}</span>
  {{#if @opcode.children}}
    <ol>
      {{#each @opcode.children key="guid" as |opcode|}}
        {{opcode-inspector opcode=opcode}}
      {{/each}}
    </ol>
  {{/if}}
</li>`);

  env.registerEmberishGlimmerComponent("block-inspector", null,
`<div>
  <h3>Opcodes</h3>
  <ol>
    {{#each @block.opcodes key="guid" as |opcode|}}
      <opcode-inspector opcode={{opcode}} />
    {{/each}}
  </ol>
  <hr />
  {{#each @block.children key="@index" as |inner|}}
    <div class="indent">{{block-inspector block=inner}}</div>
  {{/each}}
</div>`);

  env.begin();
  let self = new UpdatableReference(ui);
  let res = env.compile(UI).render(self, env, { appendTo: document.body, dynamicScope: new TestDynamicScope(null) });
  env.commit();

  rerenderUI = () => {
    self.update(ui);
    res.rerender();
  };
}
开发者ID:GCheung55,项目名称:glimmer,代码行数:101,代码来源:visualizer.ts

示例7: rerender

function rerender(context: Object={}) {
  self.update(opaque(context));
  env.begin();
  result.rerender();
  env.commit();
}
开发者ID:byelipk,项目名称:glimmer,代码行数:6,代码来源:component-test.ts


注:本文中的glimmer-test-helpers.TestEnvironment.begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。