scratch – Diff between revs 58 and 125
?pathlinks?
Rev 58 | Rev 125 | |||
---|---|---|---|---|
1 | define( [ |
1 | define([ |
|
2 | "../core", |
2 | "../core", |
|
3 | "../core/access", |
3 | "../core/access", |
|
4 | "./support", |
4 | "./support" |
|
5 | "../selector" |
- | ||
6 | ], function( jQuery, access, support ) { |
5 | ], function( jQuery, access, support ) { |
|
7 | |
- | ||
8 | "use strict"; |
- | ||
9 | |
6 | |
|
10 | var rfocusable = /^(?:input|select|textarea|button)$/i, |
- | ||
11 | rclickable = /^(?:a|area)$/i; |
7 | var rfocusable = /^(?:input|select|textarea|button)$/i; |
|
12 | |
8 | |
|
13 | jQuery.fn.extend( { |
9 | jQuery.fn.extend({ |
|
14 | prop: function( name, value ) { |
10 | prop: function( name, value ) { |
|
15 | return access( this, jQuery.prop, name, value, arguments.length > 1 ); |
11 | return access( this, jQuery.prop, name, value, arguments.length > 1 ); |
|
16 | }, |
12 | }, |
|
17 | |
13 | |
|
18 | removeProp: function( name ) { |
14 | removeProp: function( name ) { |
|
19 | return this.each( function() { |
15 | return this.each(function() { |
|
20 | delete this[ jQuery.propFix[ name ] || name ]; |
16 | delete this[ jQuery.propFix[ name ] || name ]; |
|
21 | } ); |
17 | }); |
|
22 | } |
18 | } |
|
23 | } ); |
19 | }); |
|
24 | |
20 | |
|
25 | jQuery.extend( { |
21 | jQuery.extend({ |
|
- | 22 | propFix: { |
||
- | 23 | "for": "htmlFor", |
||
- | 24 | "class": "className" |
||
- | 25 | }, |
||
- | 26 | |
||
26 | prop: function( elem, name, value ) { |
27 | prop: function( elem, name, value ) { |
|
27 | var ret, hooks, |
28 | var ret, hooks, notxml, |
|
28 | nType = elem.nodeType; |
29 | nType = elem.nodeType; |
|
29 | |
30 | |
|
30 | // Don't get/set properties on text, comment and attribute nodes |
31 | // Don't get/set properties on text, comment and attribute nodes |
|
31 | if ( nType === 3 || nType === 8 || nType === 2 ) { |
32 | if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
|
32 | return; |
33 | return; |
|
33 | } |
34 | } |
|
34 | |
35 | |
|
- | 36 | notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
||
35 | if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { |
37 | |
|
36 | |
38 | if ( notxml ) { |
|
37 | // Fix name and attach hooks |
39 | // Fix name and attach hooks |
|
38 | name = jQuery.propFix[ name ] || name; |
40 | name = jQuery.propFix[ name ] || name; |
|
39 | hooks = jQuery.propHooks[ name ]; |
41 | hooks = jQuery.propHooks[ name ]; |
|
40 | } |
42 | } |
|
41 | |
43 | |
|
42 | if ( value !== undefined ) { |
44 | if ( value !== undefined ) { |
|
43 | if ( hooks && "set" in hooks && |
- | ||
44 | ( ret = hooks.set( elem, value, name ) ) !== undefined ) { |
45 | return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? |
|
45 | return ret; |
46 | ret : |
|
46 | } |
47 | ( elem[ name ] = value ); |
|
47 | |
48 | |
|
- | 49 | } else { |
||
- | 50 | return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? |
||
- | 51 | ret : |
||
48 | return ( elem[ name ] = value ); |
52 | elem[ name ]; |
|
49 | } |
53 | } |
|
50 | |
- | ||
51 | if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { |
- | ||
52 | return ret; |
- | ||
53 | } |
- | ||
54 | |
- | ||
55 | return elem[ name ]; |
- | ||
56 | }, |
54 | }, |
|
57 | |
55 | |
|
58 | propHooks: { |
56 | propHooks: { |
|
59 | tabIndex: { |
57 | tabIndex: { |
|
60 | get: function( elem ) { |
58 | get: function( elem ) { |
|
61 | |
- | ||
62 | // Support: IE <=9 - 11 only |
- | ||
63 | // elem.tabIndex doesn't always return the |
- | ||
64 | // correct value when it hasn't been explicitly set |
- | ||
65 | // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
- | ||
66 | // Use proper attribute retrieval(#12072) |
- | ||
67 | var tabindex = jQuery.find.attr( elem, "tabindex" ); |
- | ||
68 | |
- | ||
69 | if ( tabindex ) { |
- | ||
70 | return parseInt( tabindex, 10 ); |
- | ||
71 | } |
- | ||
72 | |
- | ||
73 | if ( |
- | ||
74 | rfocusable.test( elem.nodeName ) || |
59 | return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ? |
|
75 | rclickable.test( elem.nodeName ) && |
- | ||
76 | elem.href |
60 | elem.tabIndex : |
|
77 | ) { |
61 | -1; |
|
78 | return 0; |
- | ||
79 | } |
62 | } |
|
80 | |
- | ||
81 | return -1; |
- | ||
82 | } |
63 | } |
|
83 | } |
64 | } |
|
84 | }, |
- | ||
85 | |
- | ||
86 | propFix: { |
- | ||
87 | "for": "htmlFor", |
- | ||
88 | "class": "className" |
- | ||
89 | } |
- | ||
90 | } ); |
65 | }); |
|
91 | |
- | ||
92 | // Support: IE <=11 only |
- | ||
93 | // Accessing the selectedIndex property |
- | ||
94 | // forces the browser to respect setting selected |
- | ||
95 | // on the option |
- | ||
96 | // The getter ensures a default option is selected |
- | ||
97 | // when in an optgroup |
- | ||
98 | // eslint rule "no-unused-expressions" is disabled for this code |
- | ||
99 | // since it considers such accessions noop |
66 | |
|
100 | if ( !support.optSelected ) { |
67 | if ( !support.optSelected ) { |
|
101 | jQuery.propHooks.selected = { |
68 | jQuery.propHooks.selected = { |
|
102 | get: function( elem ) { |
69 | get: function( elem ) { |
|
103 | |
- | ||
104 | /* eslint no-unused-expressions: "off" */ |
- | ||
105 | |
- | ||
106 | var parent = elem.parentNode; |
70 | var parent = elem.parentNode; |
|
107 | if ( parent && parent.parentNode ) { |
71 | if ( parent && parent.parentNode ) { |
|
108 | parent.parentNode.selectedIndex; |
72 | parent.parentNode.selectedIndex; |
|
109 | } |
73 | } |
|
110 | return null; |
74 | return null; |
|
111 | }, |
- | ||
112 | set: function( elem ) { |
- | ||
113 | |
- | ||
114 | /* eslint no-unused-expressions: "off" */ |
- | ||
115 | |
- | ||
116 | var parent = elem.parentNode; |
- | ||
117 | if ( parent ) { |
- | ||
118 | parent.selectedIndex; |
- | ||
119 | |
- | ||
120 | if ( parent.parentNode ) { |
- | ||
121 | parent.parentNode.selectedIndex; |
- | ||
122 | } |
- | ||
123 | } |
- | ||
124 | } |
75 | } |
|
125 | }; |
76 | }; |
|
126 | } |
77 | } |
|
127 | |
78 | |
|
128 | jQuery.each( [ |
79 | jQuery.each([ |
|
129 | "tabIndex", |
80 | "tabIndex", |
|
130 | "readOnly", |
81 | "readOnly", |
|
131 | "maxLength", |
82 | "maxLength", |
|
132 | "cellSpacing", |
83 | "cellSpacing", |
|
133 | "cellPadding", |
84 | "cellPadding", |
|
134 | "rowSpan", |
85 | "rowSpan", |
|
135 | "colSpan", |
86 | "colSpan", |
|
136 | "useMap", |
87 | "useMap", |
|
137 | "frameBorder", |
88 | "frameBorder", |
|
138 | "contentEditable" |
89 | "contentEditable" |
|
139 | ], function() { |
90 | ], function() { |
|
140 | jQuery.propFix[ this.toLowerCase() ] = this; |
91 | jQuery.propFix[ this.toLowerCase() ] = this; |
|
141 | } ); |
92 | }); |
|
142 | |
93 | |
|
143 | } ); |
94 | }); |
|
144 | |
95 | |