Skip to content

Commit

Permalink
Remove .attr(...,pass) shim, fixes data fns being called. Close gh-9.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmethvin committed Jan 9, 2013
1 parent 56cefda commit 0e85164
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 83 deletions.
22 changes: 0 additions & 22 deletions src/core.js
@@ -1,6 +1,5 @@

var matched, browser,
oldAccess = jQuery.access,
oldInit = jQuery.fn.init,
// Note this does NOT include the # XSS fix from 1.7!
rquickExpr = /^(?:.*(<[\w\W]+>)[^>]*|#([\w\-]*))$/;
Expand Down Expand Up @@ -29,27 +28,6 @@ jQuery.fn.init = function( selector, context, rootjQuery ) {
};
jQuery.fn.init.prototype = jQuery.fn;

if ( jQuery.fn.jquery >= "1.9" ) {
// jQuery.access( ..., pass )
jQuery.access = function( elems, fn, key, value, chainable, emptyGet, pass ) {
var i = 0,
length = elems.length;

if ( key && typeof key === "object" && value ) {
for ( i in key ) {
jQuery.access( elems, fn, i, key[i], true, emptyGet, value );
}
return elems;
} else if ( pass && key != null && value !== undefined ) {
for ( ; i < length; i++ ) {
fn( elems[i], key, value, true );
}
return elems;
}
return oldAccess.call( jQuery, elems, fn, key, value, chainable, emptyGet );
};
}

jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();

Expand Down
6 changes: 2 additions & 4 deletions src/intro.js
Expand Up @@ -2,7 +2,5 @@
"use strict";

// Use Uglify to do conditional compilation of warning messages;
// the minified version will set this to false and remove dead code.
if ( typeof window.JQMIGRATE_WARN === "undefined" ) {
window.JQMIGRATE_WARN = true;
}
// the minified version will set this to false during compilation.
window.JQMIGRATE_WARN = typeof JQMIGRATE_WARN === "undefined";
51 changes: 0 additions & 51 deletions test/attributes.js
Expand Up @@ -36,57 +36,6 @@ test( "warn if changing an input or button", function() {
});
});

test( "attr(jquery_method)", function() {
expect( 11 );
var $elem = jQuery("<div />"),
elem = $elem[ 0 ],
attrObj = {
id: "attrs",
width: 10,
height: 10,
offset: { top: 1, left: 1 },
css: { paddingLeft: 1, paddingRight: 1, color: "red" }
};

// one at a time
expectWarning( ".attr(props, true)", function() {
$elem.attr({ html: "foo" }, true );
equal( elem.innerHTML, "foo", "html" );
});

$elem.attr({ text: "bar" }, true );
equal( elem.innerHTML, "bar", "text" );

// Multiple attributes
$elem.attr( attrObj, true );
equal( elem.getAttribute("id"), "attrs", "id (attribute)" );
if ( jQuery.fn.width ) {
equal( elem.style.width, "10px", "width" );
equal( elem.style.height, "10px", "height" );
} else {
equal( elem.getAttribute("width"), "10", "width (attribute)" );
equal( elem.getAttribute("height"), "10", "height (attribute)" );
}

if ( jQuery.fn.offset ) {
equal( elem.style.top, "1px", "offset:top" );
equal( elem.style.left, "1px", "offset:left" );
} else {
equal( elem.getAttribute("offset"), "" + attrObj.offset, "offset (attribute)" );
ok( true, "no jQuery.fn.offset" );
}

if ( jQuery.css ) {
equal( elem.style.paddingLeft, "1px", "css:paddingLeft" );
equal( elem.style.paddingRight, "1px", "css:paddingRight" );
ok( /^(#ff0000|red)$/i.test( elem.style.color ), "css:color" );
} else {
equal( elem.getAttribute("css"), "" + attrObj.css, "css (attribute)" );
ok( true, "no jQuery.css" );
ok( true, "no jQuery.css" );
}
});

test( "attrHooks[\"value\"]", function() {
expect( 20 );

Expand Down
13 changes: 13 additions & 0 deletions test/data.js
@@ -1,6 +1,19 @@

module("data");

test( "basic .data() sanity check", function() {
expect( 4 );

var $foo = jQuery("#foo");

equal( $foo.data("x"), undefined, "no data initially" );
$foo.data( "x", 42 );
equal( $foo.data("x"), 42, "set a numeric value" );
$foo.data( "x", function(){ alert("whoops"); });
equal( typeof $foo.data("x"), "function", "set a function value" );
$foo.removeData("x");
equal( $foo.data("x"), undefined, "data was removed" );
});

test( "jQuery.fn.data('events')", function() {
expect( 6 );
Expand Down
6 changes: 0 additions & 6 deletions warnings.md
Expand Up @@ -81,12 +81,6 @@ $(document).ajaxStart(function(){ $("#status").text("Ajax started"); });

**Solution:** Change the program to avoid the use of global events. The jQuery Migrate plugin warns about this case but does _not_ restore the previous behavior since it was undocumented.

### JQMIGRATE: jQuery.fn.attr( props, pass ) is deprecated

**Cause**: Prior to jQuery 1.9, `$().attr()` supported an undocumented `pass` argument that was primarily used with the `$(html, props)` signature. This undocumented argument has been removed and `$(html, props)` is now implemented differently.

**Solution:** Update any code that makes use of the `pass` argument. Older versions of jQuery UI used this argument but they should be updated to version 1.8.24 at minimum for use with jQuery 1.8 or later.

### JQMIGRATE: property-based jQuery.fn.attr('value') is deprecated

**Cause**: Prior to jQuery 1.9, `$().attr("value")` retrieved the value *property* instead of the value *attribute* (which generally reflects the value that was read from HTML markup). This caused inconsistent behavior with selectors referencing the value attribute.
Expand Down

0 comments on commit 0e85164

Please sign in to comment.