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