From a196c8bca82a28c08896d31f1863cf4ecd11401c Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 4 Jun 2014 09:07:43 -0700 Subject: [PATCH] fix(jqLite): data should store data only on Element and Document nodes This is what jQuery does by default: https://github.com/jquery/jquery/blob/c18c6229c84cd2f0c9fe9f6fc3749e2c93608cc7/src/data/accepts.js#L16 We don't need to set data on text/comment nodes internally and if we don't allow setting data on these nodes, we don't need to worry about cleaning it up. BREAKING CHANGE: previously it was possible to set jqLite data on Text/Comment nodes, but now that is allowed only on Element and Document nodes just like in jQuery. We don't expect that app code actually depends on this accidental feature. --- src/jqLite.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jqLite.js b/src/jqLite.js index 3ae90fc5..fa08877c 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -316,7 +316,10 @@ function jqLiteData(element, key, value) { } if (isSetter) { - data[key] = value; + // set data only on Elements and Documents + if (element.nodeType === 1 || element.nodeType === 9) { + data[key] = value; + } } else { if (keyDefined) { if (isSimpleGetter) {