Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1e18af4

Browse files
committedJun 4, 2014
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.
1 parent b9fbfb3 commit 1e18af4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎src/jqLite.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,10 @@ function jqLiteData(element, key, value) {
315315
}
316316

317317
if (isSetter) {
318-
data[key] = value;
318+
// set data only on Elements and Documents
319+
if (element.nodeType === 1 || element.nodeType === 9) {
320+
data[key] = value;
321+
}
319322
} else {
320323
if (keyDefined) {
321324
if (isSimpleGetter) {

0 commit comments

Comments
 (0)
This repository has been archived.