Polymer observeNodes不起作用

时间:2016-04-03 17:40:31

标签: javascript polymer polymer-1.0 mutation-observers

我正在尝试一个关于SELECT subj.SubjectID AS [ID], subj.SubjectDescription AS [Subject], enrol.StuSubjEnrolmentID AS [IsEnrol] FROM [PATHWAYS].[Subjects] AS [subj] LEFT JOIN [STUDENT].[StuSubjEnrolment] AS [enrol] ON subj.SubjectID = enrol.SubjectID LEFT JOIN [STUDENT].[Student] AS [stu] ON enrol.StuID = stu.StuID AND stu.StuID = @stuID 聚合物设施的简单测试。基本上我的代码定义了组件上子节点更改的观察者。

observeNodes

此示例在创建时正常工作(从我的测试<dom-module id="wc-A"> <template> <div>Added Nodes : <span id="added"></span></div> <div>Removed Nodes : <span id="removed"></span></div> </template> <script> Polymer ({ is: 'wc-A', ready: function () { Polymer .dom (this) .observeNodes (function (nodes) { console.log (nodes) this.$.added.textContent = nodes.addedNodes.length; this.$.removed.textContent = nodes.removedNodes.length; }); } }); </script> </dom-module> 包含5而span#added包含0),但是当我以编程方式在轻DOM上添加/删除元素时,观察机制不响应(span#removed不改变)。这是我的考验:

span

可以检查完整的代码http://plnkr.co/edit/DHiH40T3pBLx9Nu6Tv3W?p=preview

我的错误是什么?提前谢谢。

1 个答案:

答案 0 :(得分:0)

您需要使用this.appendChild代替NewProducts才能使其与Polymer 1.0一起使用:

https://github.com/Polymer/polymer/issues/3102