0

I'm attempting to create a custom html tag using Mozilla's http://www.x-tags.org/. I have been able to register a test tag and use it correctly; however, I can't find any good examples of nested tags.

For example: <parent-tag parent-attribute="parent"> <child-tag child-attribute="child1"/> <child-tag>child2</child-tag> </parent-tag> I can get parent-attribute using 'accessors,' but how do I get child-attribute or value of the second child-tag?

I've seen a couple of hints that inside lifecycle of child nodes, I should reference parent nodes. However, how does that work when a set of tag hierarchy works together to create a result:

<chart-tag width="300", height="300"> <chart-x-axis isVisible="false"/> <chart-y-axis min="0" max="100"/> <chart-legend> this is the legend</chart-legend> </chart-tag>

In order to convert this made-up tag soup into a chart, I need to get all values from all nodes. Do I have to start traversing parent/sibling nodes myself?

4

1 に答える 1

0

これが最善の方法であるかどうかはわかりませんが、これを解決することができました。

親タグでは、「挿入された」ライフサイクルが呼び出されるまでに、すべての子ノードが解析され、

xtag.queryChildren(this,'child-node-tag');

子ノードへの参照を使用して、その属性をトラバースできます: childnode.attribute1

親タグと子タグを直接的に「リンク」する必要はないようですが、子タグも登録する必要があることに注意してください。非常に簡単な例がhttps://github.com/falconair/dimple-chart/blob/master/dimple-chart-test.htmにあります(バージョン履歴の早い段階でコードを見てください。時間の経過とともに進化します)。

于 2014-06-23T03:58:49.230 に答える