mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Revert "Data: do not include digits when camelCasing"
This reverts commit a254f22d7b
.
This commit is contained in:
parent
fc6ac9d1d5
commit
3b573a59d9
@ -29,7 +29,7 @@ var
|
|||||||
|
|
||||||
// Matches dashed string for camelizing
|
// Matches dashed string for camelizing
|
||||||
rmsPrefix = /^-ms-/,
|
rmsPrefix = /^-ms-/,
|
||||||
rdashAlpha = /-([a-z])/gi,
|
rdashAlpha = /-([\da-z])/gi,
|
||||||
|
|
||||||
// Used by jQuery.camelCase as callback to replace()
|
// Used by jQuery.camelCase as callback to replace()
|
||||||
fcamelCase = function( all, letter ) {
|
fcamelCase = function( all, letter ) {
|
||||||
|
@ -1648,7 +1648,7 @@ QUnit.test( "jQuery.camelCase()", function( assert ) {
|
|||||||
"foo-bar": "fooBar",
|
"foo-bar": "fooBar",
|
||||||
"foo-bar-baz": "fooBarBaz",
|
"foo-bar-baz": "fooBarBaz",
|
||||||
"girl-u-want": "girlUWant",
|
"girl-u-want": "girlUWant",
|
||||||
"the-4th-dimension": "the-4thDimension",
|
"the-4th-dimension": "the4thDimension",
|
||||||
"-o-tannenbaum": "OTannenbaum",
|
"-o-tannenbaum": "OTannenbaum",
|
||||||
"-moz-illa": "MozIlla",
|
"-moz-illa": "MozIlla",
|
||||||
"-ms-take": "msTake"
|
"-ms-take": "msTake"
|
||||||
|
@ -373,51 +373,30 @@ QUnit.test( "jQuery(plain Object).data(String, Object).data(String)", function(
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "data-* attributes", function( assert ) {
|
QUnit.test( "data-* attributes", function( assert ) {
|
||||||
assert.expect( 46 );
|
assert.expect( 43 );
|
||||||
|
|
||||||
var prop, i, l, metadata, elem,
|
var prop, i, l, metadata, elem,
|
||||||
obj, obj2, check, num, num2,
|
obj, obj2, check, num, num2,
|
||||||
parseJSON = jQuery.parseJSON,
|
parseJSON = jQuery.parseJSON,
|
||||||
div = jQuery("<div>"),
|
div = jQuery("<div>"),
|
||||||
child = jQuery(
|
child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\" data-other='test'></div>"),
|
||||||
"<div data-myobj='old data' data-ignored=\"DOM\"" +
|
dummy = jQuery("<div data-myobj='old data' data-ignored=\"DOM\" data-other='test'></div>");
|
||||||
" data-other='test' data-foo-42='boosh'></div>"
|
|
||||||
),
|
|
||||||
dummy = jQuery(
|
|
||||||
"<div data-myobj='old data' data-ignored=\"DOM\"" +
|
|
||||||
" data-other='test' data-foo-42='boosh'></div>"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.equal(
|
equal( div.data("attr"), undefined, "Check for non-existing data-attr attribute" );
|
||||||
div.data( "attr" ), undefined, "Check for non-existing data-attr attribute"
|
|
||||||
);
|
|
||||||
|
|
||||||
div.attr("data-attr", "exists");
|
div.attr("data-attr", "exists");
|
||||||
assert.equal(
|
equal( div.data("attr"), "exists", "Check for existing data-attr attribute" );
|
||||||
div.data( "attr" ), "exists", "Check for existing data-attr attribute"
|
|
||||||
);
|
|
||||||
|
|
||||||
div.attr("data-attr", "exists2");
|
div.attr("data-attr", "exists2");
|
||||||
assert.equal(
|
equal( div.data("attr"), "exists", "Check that updates to data- don't update .data()" );
|
||||||
div.data( "attr" ), "exists", "Check that updates to data- don't update .data()"
|
|
||||||
);
|
|
||||||
|
|
||||||
div.data("attr", "internal").attr("data-attr", "external");
|
div.data("attr", "internal").attr("data-attr", "external");
|
||||||
assert.equal(
|
equal( div.data("attr"), "internal", "Check for .data('attr') precedence (internal > external data-* attribute)" );
|
||||||
div.data( "attr" ),
|
|
||||||
"internal",
|
|
||||||
"Check for .data('attr') precedence (internal > external data-* attribute)"
|
|
||||||
);
|
|
||||||
|
|
||||||
div.remove();
|
div.remove();
|
||||||
|
|
||||||
child.appendTo("#qunit-fixture");
|
child.appendTo("#qunit-fixture");
|
||||||
assert.equal(
|
equal( child.data("myobj"), "old data", "Value accessed from data-* attribute");
|
||||||
child.data( "myobj" ), "old data", "Value accessed from data-* attribute"
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
child.data( "foo-42" ), "boosh", "camelCasing does not affect numbers (#1751)"
|
|
||||||
);
|
|
||||||
|
|
||||||
child.data( "myobj", "replaced" );
|
child.data( "myobj", "replaced" );
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@ -431,7 +410,7 @@ QUnit.test( "data-* attributes", function( assert ) {
|
|||||||
|
|
||||||
obj = child.data();
|
obj = child.data();
|
||||||
obj2 = dummy.data();
|
obj2 = dummy.data();
|
||||||
check = [ "myobj", "ignored", "other", "foo-42" ];
|
check = [ "myobj", "ignored", "other" ];
|
||||||
num = 0;
|
num = 0;
|
||||||
num2 = 0;
|
num2 = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user