scratch – Diff between revs 58 and 125
?pathlinks?
Rev 58 | Rev 125 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
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 ) { |
|
Line 7... | Line -... | |||
7 | |
- | ||
8 | "use strict"; |
- | ||
9 | |
6 | |
|
10 | var rfocusable = /^(?:input|select|textarea|button)$/i, |
- | ||
Line 11... | Line 7... | |||
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 ) { |
|
Line 21... | Line 17... | |||
21 | } ); |
17 | }); |
|
22 | } |
18 | } |
|
23 | } ); |
19 | }); |
|
Line 24... | Line 20... | |||
24 | |
20 | |
|
- | 21 | jQuery.extend({ |
||
- | 22 | propFix: { |
||
- | 23 | "for": "htmlFor", |
||
- | 24 | "class": "className" |
||
- | 25 | }, |
||
25 | jQuery.extend( { |
26 | |
|
26 | prop: function( elem, name, value ) { |
27 | prop: function( elem, name, value ) { |
|
27 | var ret, hooks, |
28 | var ret, hooks, notxml, |
|
Line 28... | Line 29... | |||
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 ) { |
|
Line 32... | Line 33... | |||
32 | return; |
33 | return; |
|
Line -... | Line 34... | |||
- | 34 | } |
||
33 | } |
35 | |
|
34 | |
36 | notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
|
35 | if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { |
37 | |
|
36 | |
38 | if ( notxml ) { |
|
Line 37... | Line 39... | |||
37 | // Fix name and attach hooks |
39 | // Fix name and attach hooks |
|
38 | name = jQuery.propFix[ name ] || name; |
- | ||
39 | hooks = jQuery.propHooks[ name ]; |
40 | name = jQuery.propFix[ name ] || name; |
|
40 | } |
41 | hooks = jQuery.propHooks[ name ]; |
|
41 | |
42 | } |
|
42 | if ( value !== undefined ) { |
43 | |
|
- | 44 | if ( value !== undefined ) { |
||
- | 45 | return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? |
||
- | 46 | ret : |
||
43 | if ( hooks && "set" in hooks && |
47 | ( elem[ name ] = value ); |
|
44 | ( ret = hooks.set( elem, value, name ) ) !== undefined ) { |
48 | |
|
45 | return ret; |
- | ||
46 | } |
- | ||
47 | |
- | ||
48 | return ( elem[ name ] = value ); |
- | ||
49 | } |
- | ||
50 | |
- | ||
51 | if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { |
49 | } else { |
|
Line 52... | Line 50... | |||
52 | return ret; |
50 | return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? |
|
53 | } |
51 | ret : |
|
54 | |
52 | elem[ name ]; |
|
55 | return elem[ name ]; |
- | ||
56 | }, |
- | ||
57 | |
- | ||
58 | propHooks: { |
- | ||
59 | tabIndex: { |
- | ||
60 | 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 | |
53 | } |
|
69 | if ( tabindex ) { |
- | ||
70 | return parseInt( tabindex, 10 ); |
54 | }, |
|
71 | } |
55 | |
|
72 | |
- | ||
73 | if ( |
56 | propHooks: { |
|
74 | rfocusable.test( elem.nodeName ) || |
- | ||
75 | rclickable.test( elem.nodeName ) && |
- | ||
76 | elem.href |
57 | tabIndex: { |
|
77 | ) { |
58 | get: function( elem ) { |
|
78 | return 0; |
- | ||
79 | } |
- | ||
80 | |
- | ||
81 | return -1; |
- | ||
82 | } |
- | ||
83 | } |
- | ||
84 | }, |
59 | return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ? |
|
Line 85... | Line -... | |||
85 | |
- | ||
86 | propFix: { |
- | ||
87 | "for": "htmlFor", |
- | ||
88 | "class": "className" |
- | ||
89 | } |
- | ||
90 | } ); |
- | ||
91 | |
- | ||
92 | // Support: IE <=11 only |
- | ||
93 | // Accessing the selectedIndex property |
60 | elem.tabIndex : |
|
94 | // forces the browser to respect setting selected |
61 | -1; |
|
95 | // on the option |
62 | } |
|
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 |
63 | } |
|
100 | if ( !support.optSelected ) { |
64 | } |
|
101 | jQuery.propHooks.selected = { |
65 | }); |
|
102 | get: function( elem ) { |
66 | |
|
103 | |
67 | if ( !support.optSelected ) { |
|
104 | /* eslint no-unused-expressions: "off" */ |
- | ||
105 | |
- | ||
106 | var parent = elem.parentNode; |
- | ||
107 | if ( parent && parent.parentNode ) { |
- | ||
108 | parent.parentNode.selectedIndex; |
- | ||
109 | } |
- | ||
110 | return null; |
- | ||
111 | }, |
- | ||
112 | set: function( elem ) { |
- | ||
113 | |
- | ||
114 | /* eslint no-unused-expressions: "off" */ |
- | ||
115 | |
- | ||
116 | var parent = elem.parentNode; |
- | ||
117 | if ( parent ) { |
68 | jQuery.propHooks.selected = { |
|
118 | parent.selectedIndex; |
69 | get: function( elem ) { |
|
119 | |
70 | var parent = elem.parentNode; |
|
Line 120... | Line 71... | |||
120 | if ( parent.parentNode ) { |
71 | if ( parent && parent.parentNode ) { |