Skip to content
Permalink
Browse files

Merge remote-tracking branch 'upstream/master' into bug_13514

  • Loading branch information
ruado1987 committed Mar 4, 2013
2 parents 13860db + 49abe3d commit 63174e0ac9484bb8573714a2b8a605edd54ad386
Showing with 25 additions and 11 deletions.
  1. +7 −4 src/data.js
  2. +18 −7 test/unit/data.js
@@ -85,7 +85,7 @@ Data.prototype = {
// Either a valid cache is found, or will be created.
// New caches will be created and the unlock returned,
// allowing direct access to the newly created
// empty data object.
// empty data object. A valid owner object must be provided.
var cache = this.cache[ this.key( owner ) ];

return key === undefined ?
@@ -255,9 +255,12 @@ jQuery.fn.extend({
var data,
camelKey = jQuery.camelCase( key );

// Get the Data...
if ( value === undefined ) {

// The calling jQuery object (element matches) is not empty
// (and therefore has an element appears at this[0]) and the
// `value` parameter was not undefined. An empty jQuery object
// will result in `undefined` for elem = this[0] which will
// throw an exception if an attempt to read a data cache is made.
if ( elem && value === undefined ) {
// Attempt to get data from the cache
// with the key as-is
data = data_user.get( elem, key );
@@ -469,7 +469,7 @@ if (window.JSON && window.JSON.stringify) {
});
}

test("jQuery.data should follow html5 specification regarding camel casing", function() {
test(".data should follow html5 specification regarding camel casing", function() {
expect(12);

var div = jQuery("<div id='myObject' data-w-t-f='ftw' data-big-a-little-a='bouncing-b' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>")
@@ -535,7 +535,7 @@ test(".data should not miss attr() set data-* with hyphenated property names", f
deepEqual( b.data("long-param"), { a: 2 }, "data with property long-param was found, 2" );
});

test("jQuery.data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {
test(".data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {

var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
datas = {
@@ -566,7 +566,7 @@ test("jQuery.data supports interoperable hyphenated/camelCase get/set of propert
});
});

test("jQuery.data supports interoperable removal of hyphenated/camelCase properties", function() {
test(".data supports interoperable removal of hyphenated/camelCase properties", function() {
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
datas = {
"non-empty": "a string",
@@ -598,7 +598,7 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
});
});

test( "jQuery.fn.removeData supports removal of hyphenated properties via array (#12786)", function( assert ) {
test( ".removeData supports removal of hyphenated properties via array (#12786)", function( assert ) {
expect( 4 );

var div, plain, compare;
@@ -631,7 +631,7 @@ test( "jQuery.fn.removeData supports removal of hyphenated properties via array
});

// Test originally by Moschel
test("Triggering the removeData should not throw exceptions. (#10080)", function() {
test(".removeData should not throw exceptions. (#10080)", function() {
expect(1);
stop();
var frame = jQuery("#loadediframe");
@@ -643,7 +643,7 @@ test("Triggering the removeData should not throw exceptions. (#10080)", function
frame.attr("src", "data/iframe.html?param=true");
});

test( "Only check element attributes once when calling .data() - #8909", function() {
test( ".data only checks element attributes once. #8909", function() {
expect( 2 );
var testing = {
"test": "testing",
@@ -663,10 +663,21 @@ test( "Only check element attributes once when calling .data() - #8909", functio
element.remove();
});

test( "JSON data- attributes can have newlines", function() {
test( "data-* with JSON value can have newlines", function() {
expect(1);

var x = jQuery("<div data-some='{\n\"foo\":\n\t\"bar\"\n}'></div>");
equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" );
x.remove();
});

test(".data doesn't throw when calling selection is empty. #13551", function() {
expect(1);

try {
jQuery( null ).data( "prop" );
ok( true, "jQuery(null).data('prop') does not throw" );
} catch ( e ) {
ok( false, e.message );
}
});

0 comments on commit 63174e0

Please sign in to comment.
You can’t perform that action at this time.