Permalink
Browse files

Remove .attr(...,pass) shim, fixes data fns being called. Close gh-9.

  • Loading branch information...
1 parent 56cefda commit 0e85164aaaa8acaafa75d6fb3d65305cb7e40431 @dmethvin dmethvin committed Jan 9, 2013
Showing with 15 additions and 83 deletions.
  1. +0 −22 src/core.js
  2. +2 −4 src/intro.js
  3. +0 −51 test/attributes.js
  4. +13 −0 test/data.js
  5. +0 −6 warnings.md
View
@@ -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\-]*))$/;
@@ -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();
View
@@ -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";
View
@@ -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 );
View
@@ -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 );
View
@@ -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.

0 comments on commit 0e85164

Please sign in to comment.