diff --git a/entries/data.xml b/entries/data.xml index 80ccee99..3606395d 100644 --- a/entries/data.xml +++ b/entries/data.xml @@ -31,7 +31,7 @@ $( "body" ).data(); // { foo: 52, bar: { myType: "test", count: 40 }, baz: [ 1,
In jQuery 1.4.3 setting an element's data object with .data(obj)
extends the data previously stored with that element.
Prior to jQuery 1.4.3 (starting in jQuery 1.4) the .data()
method completely replaced all data, instead of just extending the data object. If you are using third-party plugins it may not be advisable to completely replace the element's data object, since plugins may have also set data.
jQuery 3 changes the behavior of this method to align it to the Dataset API specifications. Specifically, jQuery 3 transforms every two-character sequence of "-" (U+002D) followed by a lowercase ASCII letter by the uppercase version of the letter as per definition of [the algorithm of the Dataset API](http://www.w3.org/TR/html5/dom.html#dom-dataset). Writing a statement like $( "body" ).data( { "my-name": "aValue" } ).data();
will return { myName: "aValue" }
.
jQuery 3 changes the behavior of this method to align it to the Dataset API specifications. Specifically, jQuery 3 transforms every two-character sequence of "-" (U+002D) followed by a lowercase ASCII letter by the uppercase version of the letter as per definition of the algorithm of the Dataset API. Writing a statement like $( "body" ).data( { "my-name": "aValue" } ).data();
will return { myName: "aValue" }
.
Due to the way browsers interact with plugins and external code, the .data()
method cannot be used on <object>
(unless it's a Flash plugin), <applet>
or <embed>
elements.