mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-08 22:37:20 +08:00
fix(jqLite): data should store data only on Element and Document nodes
This is what jQuery does by default: c18c6229c8/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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user