【问题标题】:How to use dom-bind within test-fixture?如何在测试夹具中使用 dom-bind?
【发布时间】:2016-01-07 21:59:36
【问题描述】:

如何在<test-fixture> 中使用<template is="dom-bind">web-components-tester

我尝试使用 Polymer 0.8 x-template 方式:

<test-fixture id="dom-bind-fixture">
    <template is="dom-bind">
        <h1>{{greeting}}</h2>
    </template>
</test-fixture>
<script>
    // ...
   var bound = fixture('dom-bind-fixture', {greeting: 'ohai thurr'});
</script>

这自然会失败,因为dom-bind 没有stamp 方法。

然后,我尝试将其从原生 &lt;template&gt; 元素中剔除:

<test-fixture id="dom-bind-fixture">
    <template>
        <h1>outside dom-bind</h1>
        <template is="dom-bind">
            <h2>inside dom-bind</h2>
        </template>
    </template>
</test-fixture>

但在非 Chrome 浏览器中,此标签仅标记 outside dom-bind

有没有办法让它工作,或者它只是 web-components-tester/test-fixture/dom-bind 中的一个阻塞错误?

【问题讨论】:

  • 作为参考,@tomalec 创建了一个GitHub issue 来跟踪这个。

标签: polymer web-component web-component-tester


【解决方案1】:

使用dom-template,即:

<test-fixture id="dom-bind-fixture">
    <template is="dom-template">
        <h1>{{greeting}}</h2>
    </template>
</test-fixture>
<script>
    // ...
   var bound = fixture('dom-bind-fixture', {greeting: 'ohai thurr'});
</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-17
    • 2015-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-23
    • 1970-01-01
    • 2016-09-09
    相关资源
    最近更新 更多