问题
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