How to get rid of #text elelment when use polymer dom api

删除回忆录丶 提交于 2019-12-11 12:32:43

问题


Trying to instantiate template using Polymer.Templatizer behavior.

Here is simple template:

<template>
        <div>
          item
        </div>
</template>

Here is code that should create element from given template:

//template variable was initialized from selectors in **create** event of component that uses this template
this.templatize(template);
var clone = this.stamp({});
console.log(clone.root);

I was sure that root is pointer to template's inner and single div element. But below is real output of console.log in mozilla:

DocumentFragment [#text " ", 
    <div class="style-scope week-selector">, 
    #text " "]

Seems that it' propriate behavior and this output reflects real dom structure. But is there any handy way to avoid checking what Polymer dom api methods return every time and have a deal only with "true" elements of dom tree disregarding fake #text nodes.

来源:https://stackoverflow.com/questions/35204949/how-to-get-rid-of-text-elelment-when-use-polymer-dom-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!