Blame view

app/bower_components/jquery/src/attributes/prop.js 2.93 KB
87c93a029   Dang YoungWorld   add modal
1
  define( [
f986e111b   TRUONG   add libs
2
3
  	"../core",
  	"../core/access",
87c93a029   Dang YoungWorld   add modal
4
5
  	"./support",
  	"../selector"
f986e111b   TRUONG   add libs
6
  ], function( jQuery, access, support ) {
87c93a029   Dang YoungWorld   add modal
7
8
9
  "use strict";
  
  var rfocusable = /^(?:input|select|textarea|button)$/i,
f986e111b   TRUONG   add libs
10
  	rclickable = /^(?:a|area)$/i;
87c93a029   Dang YoungWorld   add modal
11
  jQuery.fn.extend( {
f986e111b   TRUONG   add libs
12
13
14
15
16
  	prop: function( name, value ) {
  		return access( this, jQuery.prop, name, value, arguments.length > 1 );
  	},
  
  	removeProp: function( name ) {
87c93a029   Dang YoungWorld   add modal
17
18
19
  		return this.each( function() {
  			delete this[ jQuery.propFix[ name ] || name ];
  		} );
f986e111b   TRUONG   add libs
20
  	}
87c93a029   Dang YoungWorld   add modal
21
  } );
f986e111b   TRUONG   add libs
22

87c93a029   Dang YoungWorld   add modal
23
  jQuery.extend( {
f986e111b   TRUONG   add libs
24
  	prop: function( elem, name, value ) {
87c93a029   Dang YoungWorld   add modal
25
  		var ret, hooks,
f986e111b   TRUONG   add libs
26
  			nType = elem.nodeType;
87c93a029   Dang YoungWorld   add modal
27
28
  		// Don't get/set properties on text, comment and attribute nodes
  		if ( nType === 3 || nType === 8 || nType === 2 ) {
f986e111b   TRUONG   add libs
29
30
  			return;
  		}
87c93a029   Dang YoungWorld   add modal
31
  		if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
f986e111b   TRUONG   add libs
32

f986e111b   TRUONG   add libs
33
34
35
36
37
38
  			// Fix name and attach hooks
  			name = jQuery.propFix[ name ] || name;
  			hooks = jQuery.propHooks[ name ];
  		}
  
  		if ( value !== undefined ) {
87c93a029   Dang YoungWorld   add modal
39
40
41
42
43
44
  			if ( hooks && "set" in hooks &&
  				( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  				return ret;
  			}
  
  			return ( elem[ name ] = value );
f986e111b   TRUONG   add libs
45
  		}
87c93a029   Dang YoungWorld   add modal
46
47
48
49
50
51
  
  		if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  			return ret;
  		}
  
  		return elem[ name ];
f986e111b   TRUONG   add libs
52
53
54
55
56
  	},
  
  	propHooks: {
  		tabIndex: {
  			get: function( elem ) {
87c93a029   Dang YoungWorld   add modal
57
58
59
60
61
  
  				// Support: IE <=9 - 11 only
  				// elem.tabIndex doesn't always return the
  				// correct value when it hasn't been explicitly set
  				// https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
f986e111b   TRUONG   add libs
62
63
  				// Use proper attribute retrieval(#12072)
  				var tabindex = jQuery.find.attr( elem, "tabindex" );
87c93a029   Dang YoungWorld   add modal
64
65
66
67
68
69
70
71
72
73
74
75
76
  				if ( tabindex ) {
  					return parseInt( tabindex, 10 );
  				}
  
  				if (
  					rfocusable.test( elem.nodeName ) ||
  					rclickable.test( elem.nodeName ) &&
  					elem.href
  				) {
  					return 0;
  				}
  
  				return -1;
f986e111b   TRUONG   add libs
77
78
  			}
  		}
87c93a029   Dang YoungWorld   add modal
79
  	},
f986e111b   TRUONG   add libs
80

87c93a029   Dang YoungWorld   add modal
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  	propFix: {
  		"for": "htmlFor",
  		"class": "className"
  	}
  } );
  
  // Support: IE <=11 only
  // Accessing the selectedIndex property
  // forces the browser to respect setting selected
  // on the option
  // The getter ensures a default option is selected
  // when in an optgroup
  // eslint rule "no-unused-expressions" is disabled for this code
  // since it considers such accessions noop
f986e111b   TRUONG   add libs
95
96
97
  if ( !support.optSelected ) {
  	jQuery.propHooks.selected = {
  		get: function( elem ) {
87c93a029   Dang YoungWorld   add modal
98
99
  
  			/* eslint no-unused-expressions: "off" */
f986e111b   TRUONG   add libs
100
  			var parent = elem.parentNode;
87c93a029   Dang YoungWorld   add modal
101
102
103
104
105
106
107
108
  			if ( parent && parent.parentNode ) {
  				parent.parentNode.selectedIndex;
  			}
  			return null;
  		},
  		set: function( elem ) {
  
  			/* eslint no-unused-expressions: "off" */
f986e111b   TRUONG   add libs
109

87c93a029   Dang YoungWorld   add modal
110
  			var parent = elem.parentNode;
f986e111b   TRUONG   add libs
111
112
  			if ( parent ) {
  				parent.selectedIndex;
f986e111b   TRUONG   add libs
113
114
115
116
  				if ( parent.parentNode ) {
  					parent.parentNode.selectedIndex;
  				}
  			}
f986e111b   TRUONG   add libs
117
118
119
  		}
  	};
  }
87c93a029   Dang YoungWorld   add modal
120
  jQuery.each( [
f986e111b   TRUONG   add libs
121
122
123
124
125
126
127
128
129
130
131
132
  	"tabIndex",
  	"readOnly",
  	"maxLength",
  	"cellSpacing",
  	"cellPadding",
  	"rowSpan",
  	"colSpan",
  	"useMap",
  	"frameBorder",
  	"contentEditable"
  ], function() {
  	jQuery.propFix[ this.toLowerCase() ] = this;
87c93a029   Dang YoungWorld   add modal
133
  } );
f986e111b   TRUONG   add libs
134

87c93a029   Dang YoungWorld   add modal
135
  } );