Blame view

bower_components/jquery/src/attributes/prop.js 2.21 KB
a1a3bc73   Luigi Serra   graphs updates
1
  define( [
74249687   Luigi Serra   Cross browser con...
2
3
  	"../core",
  	"../core/access",
a1a3bc73   Luigi Serra   graphs updates
4
5
  	"./support",
  	"../selector"
74249687   Luigi Serra   Cross browser con...
6
7
  ], function( jQuery, access, support ) {
  
a1a3bc73   Luigi Serra   graphs updates
8
9
  var rfocusable = /^(?:input|select|textarea|button)$/i,
  	rclickable = /^(?:a|area)$/i;
74249687   Luigi Serra   Cross browser con...
10
  
a1a3bc73   Luigi Serra   graphs updates
11
  jQuery.fn.extend( {
74249687   Luigi Serra   Cross browser con...
12
13
14
15
16
  	prop: function( name, value ) {
  		return access( this, jQuery.prop, name, value, arguments.length > 1 );
  	},
  
  	removeProp: function( name ) {
a1a3bc73   Luigi Serra   graphs updates
17
  		return this.each( function() {
74249687   Luigi Serra   Cross browser con...
18
  			delete this[ jQuery.propFix[ name ] || name ];
a1a3bc73   Luigi Serra   graphs updates
19
  		} );
74249687   Luigi Serra   Cross browser con...
20
  	}
a1a3bc73   Luigi Serra   graphs updates
21
  } );
74249687   Luigi Serra   Cross browser con...
22
  
a1a3bc73   Luigi Serra   graphs updates
23
  jQuery.extend( {
74249687   Luigi Serra   Cross browser con...
24
  	prop: function( elem, name, value ) {
a1a3bc73   Luigi Serra   graphs updates
25
  		var ret, hooks,
74249687   Luigi Serra   Cross browser con...
26
27
28
  			nType = elem.nodeType;
  
  		// Don't get/set properties on text, comment and attribute nodes
a1a3bc73   Luigi Serra   graphs updates
29
  		if ( nType === 3 || nType === 8 || nType === 2 ) {
74249687   Luigi Serra   Cross browser con...
30
31
32
  			return;
  		}
  
a1a3bc73   Luigi Serra   graphs updates
33
  		if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
74249687   Luigi Serra   Cross browser con...
34
  
74249687   Luigi Serra   Cross browser con...
35
36
37
38
39
40
  			// Fix name and attach hooks
  			name = jQuery.propFix[ name ] || name;
  			hooks = jQuery.propHooks[ name ];
  		}
  
  		if ( value !== undefined ) {
a1a3bc73   Luigi Serra   graphs updates
41
42
43
44
45
46
47
48
49
50
  			if ( hooks && "set" in hooks &&
  				( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  				return ret;
  			}
  
  			return ( elem[ name ] = value );
  		}
  
  		if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  			return ret;
74249687   Luigi Serra   Cross browser con...
51
  		}
a1a3bc73   Luigi Serra   graphs updates
52
53
  
  		return elem[ name ];
74249687   Luigi Serra   Cross browser con...
54
55
56
57
58
  	},
  
  	propHooks: {
  		tabIndex: {
  			get: function( elem ) {
a1a3bc73   Luigi Serra   graphs updates
59
60
61
62
63
64
65
66
67
68
69
70
71
  
  				// elem.tabIndex doesn't always return the
  				// correct value when it hasn't been explicitly set
  				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  				// Use proper attribute retrieval(#12072)
  				var tabindex = jQuery.find.attr( elem, "tabindex" );
  
  				return tabindex ?
  					parseInt( tabindex, 10 ) :
  					rfocusable.test( elem.nodeName ) ||
  						rclickable.test( elem.nodeName ) && elem.href ?
  							0 :
  							-1;
74249687   Luigi Serra   Cross browser con...
72
73
  			}
  		}
a1a3bc73   Luigi Serra   graphs updates
74
75
76
77
78
  	},
  
  	propFix: {
  		"for": "htmlFor",
  		"class": "className"
74249687   Luigi Serra   Cross browser con...
79
  	}
a1a3bc73   Luigi Serra   graphs updates
80
  } );
74249687   Luigi Serra   Cross browser con...
81
82
83
84
85
86
87
88
89
90
91
92
93
  
  if ( !support.optSelected ) {
  	jQuery.propHooks.selected = {
  		get: function( elem ) {
  			var parent = elem.parentNode;
  			if ( parent && parent.parentNode ) {
  				parent.parentNode.selectedIndex;
  			}
  			return null;
  		}
  	};
  }
  
a1a3bc73   Luigi Serra   graphs updates
94
  jQuery.each( [
74249687   Luigi Serra   Cross browser con...
95
96
97
98
99
100
101
102
103
104
105
106
  	"tabIndex",
  	"readOnly",
  	"maxLength",
  	"cellSpacing",
  	"cellPadding",
  	"rowSpan",
  	"colSpan",
  	"useMap",
  	"frameBorder",
  	"contentEditable"
  ], function() {
  	jQuery.propFix[ this.toLowerCase() ] = this;
a1a3bc73   Luigi Serra   graphs updates
107
  } );
74249687   Luigi Serra   Cross browser con...
108
  
a1a3bc73   Luigi Serra   graphs updates
109
  } );