root / drupal7 / sites / all / libraries / flexslider-2.5.0 / bower_components / jquery / src / attributes / prop.js @ 0aee3c58
1 |
define([ |
---|---|
2 |
"../core",
|
3 |
"../core/access",
|
4 |
"./support"
|
5 |
], function( jQuery, access, support ) {
|
6 |
|
7 |
var rfocusable = /^(?:input|select|textarea|button|object)$/i, |
8 |
rclickable = /^(?:a|area)$/i;
|
9 |
|
10 |
jQuery.fn.extend({ |
11 |
prop: function( name, value ) { |
12 |
return access( this, jQuery.prop, name, value, arguments.length > 1 ); |
13 |
}, |
14 |
|
15 |
removeProp: function( name ) { |
16 |
name = jQuery.propFix[ name ] || name; |
17 |
return this.each(function() { |
18 |
// try/catch handles cases where IE balks (such as removing a property on window)
|
19 |
try {
|
20 |
this[ name ] = undefined; |
21 |
delete this[ name ]; |
22 |
} catch( e ) {}
|
23 |
}); |
24 |
} |
25 |
}); |
26 |
|
27 |
jQuery.extend({ |
28 |
propFix: {
|
29 |
"for": "htmlFor", |
30 |
"class": "className" |
31 |
}, |
32 |
|
33 |
prop: function( elem, name, value ) { |
34 |
var ret, hooks, notxml,
|
35 |
nType = elem.nodeType; |
36 |
|
37 |
// don't get/set properties on text, comment and attribute nodes
|
38 |
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
39 |
return;
|
40 |
} |
41 |
|
42 |
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
43 |
|
44 |
if ( notxml ) {
|
45 |
// Fix name and attach hooks
|
46 |
name = jQuery.propFix[ name ] || name; |
47 |
hooks = jQuery.propHooks[ name ]; |
48 |
} |
49 |
|
50 |
if ( value !== undefined ) { |
51 |
return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? |
52 |
ret : |
53 |
( elem[ name ] = value ); |
54 |
|
55 |
} else {
|
56 |
return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? |
57 |
ret : |
58 |
elem[ name ]; |
59 |
} |
60 |
}, |
61 |
|
62 |
propHooks: {
|
63 |
tabIndex: {
|
64 |
get: function( elem ) { |
65 |
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
66 |
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
67 |
// Use proper attribute retrieval(#12072)
|
68 |
var tabindex = jQuery.find.attr( elem, "tabindex" ); |
69 |
|
70 |
return tabindex ?
|
71 |
parseInt( tabindex, 10 ) :
|
72 |
rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
73 |
0 :
|
74 |
-1;
|
75 |
} |
76 |
} |
77 |
} |
78 |
}); |
79 |
|
80 |
// Some attributes require a special call on IE
|
81 |
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
|
82 |
if ( !support.hrefNormalized ) {
|
83 |
// href/src property should get the full normalized URL (#10299/#12915)
|
84 |
jQuery.each([ "href", "src" ], function( i, name ) { |
85 |
jQuery.propHooks[ name ] = { |
86 |
get: function( elem ) { |
87 |
return elem.getAttribute( name, 4 ); |
88 |
} |
89 |
}; |
90 |
}); |
91 |
} |
92 |
|
93 |
// Support: Safari, IE9+
|
94 |
// mis-reports the default selected property of an option
|
95 |
// Accessing the parent's selectedIndex property fixes it
|
96 |
if ( !support.optSelected ) {
|
97 |
jQuery.propHooks.selected = { |
98 |
get: function( elem ) { |
99 |
var parent = elem.parentNode;
|
100 |
|
101 |
if ( parent ) {
|
102 |
parent.selectedIndex; |
103 |
|
104 |
// Make sure that it also works with optgroups, see #5701
|
105 |
if ( parent.parentNode ) {
|
106 |
parent.parentNode.selectedIndex; |
107 |
} |
108 |
} |
109 |
return null; |
110 |
} |
111 |
}; |
112 |
} |
113 |
|
114 |
jQuery.each([ |
115 |
"tabIndex",
|
116 |
"readOnly",
|
117 |
"maxLength",
|
118 |
"cellSpacing",
|
119 |
"cellPadding",
|
120 |
"rowSpan",
|
121 |
"colSpan",
|
122 |
"useMap",
|
123 |
"frameBorder",
|
124 |
"contentEditable"
|
125 |
], function() {
|
126 |
jQuery.propFix[ this.toLowerCase() ] = this; |
127 |
}); |
128 |
|
129 |
// IE6/7 call enctype encoding
|
130 |
if ( !support.enctype ) {
|
131 |
jQuery.propFix.enctype = "encoding";
|
132 |
} |
133 |
|
134 |
}); |