Blame view

bower_components/jquery/src/attributes/prop.js 1.81 KB
c5169e0e   Renato De Donato   a new hope
1
  define([
74249687   Luigi Serra   Cross browser con...
2
3
  	"../core",
  	"../core/access",
c5169e0e   Renato De Donato   a new hope
4
  	"./support"
74249687   Luigi Serra   Cross browser con...
5
6
  ], function( jQuery, access, support ) {
  
c5169e0e   Renato De Donato   a new hope
7
  var rfocusable = /^(?:input|select|textarea|button)$/i;
74249687   Luigi Serra   Cross browser con...
8
  
c5169e0e   Renato De Donato   a new hope
9
  jQuery.fn.extend({
74249687   Luigi Serra   Cross browser con...
10
11
12
13
14
  	prop: function( name, value ) {
  		return access( this, jQuery.prop, name, value, arguments.length > 1 );
  	},
  
  	removeProp: function( name ) {
c5169e0e   Renato De Donato   a new hope
15
  		return this.each(function() {
74249687   Luigi Serra   Cross browser con...
16
  			delete this[ jQuery.propFix[ name ] || name ];
c5169e0e   Renato De Donato   a new hope
17
  		});
74249687   Luigi Serra   Cross browser con...
18
  	}
c5169e0e   Renato De Donato   a new hope
19
20
21
22
23
24
25
  });
  
  jQuery.extend({
  	propFix: {
  		"for": "htmlFor",
  		"class": "className"
  	},
74249687   Luigi Serra   Cross browser con...
26
  
74249687   Luigi Serra   Cross browser con...
27
  	prop: function( elem, name, value ) {
c5169e0e   Renato De Donato   a new hope
28
  		var ret, hooks, notxml,
74249687   Luigi Serra   Cross browser con...
29
30
31
  			nType = elem.nodeType;
  
  		// Don't get/set properties on text, comment and attribute nodes
c5169e0e   Renato De Donato   a new hope
32
  		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
74249687   Luigi Serra   Cross browser con...
33
34
35
  			return;
  		}
  
c5169e0e   Renato De Donato   a new hope
36
  		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
74249687   Luigi Serra   Cross browser con...
37
  
c5169e0e   Renato De Donato   a new hope
38
  		if ( notxml ) {
74249687   Luigi Serra   Cross browser con...
39
40
41
42
43
44
  			// Fix name and attach hooks
  			name = jQuery.propFix[ name ] || name;
  			hooks = jQuery.propHooks[ name ];
  		}
  
  		if ( value !== undefined ) {
c5169e0e   Renato De Donato   a new hope
45
46
47
48
49
50
51
52
  			return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
  				ret :
  				( elem[ name ] = value );
  
  		} else {
  			return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
  				ret :
  				elem[ name ];
74249687   Luigi Serra   Cross browser con...
53
  		}
74249687   Luigi Serra   Cross browser con...
54
55
56
57
58
  	},
  
  	propHooks: {
  		tabIndex: {
  			get: function( elem ) {
c5169e0e   Renato De Donato   a new hope
59
60
61
  				return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
  					elem.tabIndex :
  					-1;
74249687   Luigi Serra   Cross browser con...
62
63
  			}
  		}
74249687   Luigi Serra   Cross browser con...
64
  	}
c5169e0e   Renato De Donato   a new hope
65
  });
74249687   Luigi Serra   Cross browser con...
66
67
68
69
70
71
72
73
74
75
76
77
78
  
  if ( !support.optSelected ) {
  	jQuery.propHooks.selected = {
  		get: function( elem ) {
  			var parent = elem.parentNode;
  			if ( parent && parent.parentNode ) {
  				parent.parentNode.selectedIndex;
  			}
  			return null;
  		}
  	};
  }
  
c5169e0e   Renato De Donato   a new hope
79
  jQuery.each([
74249687   Luigi Serra   Cross browser con...
80
81
82
83
84
85
86
87
88
89
90
91
  	"tabIndex",
  	"readOnly",
  	"maxLength",
  	"cellSpacing",
  	"cellPadding",
  	"rowSpan",
  	"colSpan",
  	"useMap",
  	"frameBorder",
  	"contentEditable"
  ], function() {
  	jQuery.propFix[ this.toLowerCase() ] = this;
c5169e0e   Renato De Donato   a new hope
92
  });
74249687   Luigi Serra   Cross browser con...
93
  
c5169e0e   Renato De Donato   a new hope
94
  });