From 9989928c6291c30fc0ff774e4bd9f9127d10a67c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 23 Jun 2014 15:38:51 +0200 Subject: [PATCH] smartxml: caching text nodes via expando --- src/smartxml/smartxml.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index 9cff5ec..c0b3c42 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -280,6 +280,7 @@ $.extend(ElementNode.prototype, { var TextNode = function(nativeNode, document) { DocumentNode.call(this, nativeNode, document); + nativeNode.__smartxmlTextNodeInstance = this; }; TextNode.prototype = Object.create(DocumentNode.prototype); @@ -360,7 +361,8 @@ $.extend(Document.prototype, Backbone.Events, fragments, { var cached; if(from instanceof Node) { - cached = ($(from).data(privateKey) || {}).node; + /* globals Text */ + cached = from instanceof Text ? from.__smartxmlTextNodeInstance : ($(from).data(privateKey) || {}).node; if(cached instanceof DocumentNode) { return cached; } -- 2.20.1