xonecas.io
286
Sf

simple-flask-coffee-sass-boilerplate / files

simple-flask-coffee-sass-boilerplate / bower_components / jquery / src / attributes / prop.js

1.9 KB
1define([
2	"../core",
3	"../core/access",
4	"./support"
5], function( jQuery, access, support ) {
6
7var rfocusable = /^(?:input|select|textarea|button)$/i;
8
9jQuery.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
21jQuery.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// Support: IE9+
68// Selectedness for an option in an optgroup can be inaccurate
69if ( !support.optSelected ) {
70	jQuery.propHooks.selected = {
71		get: function( elem ) {
72			var parent = elem.parentNode;
73			if ( parent && parent.parentNode ) {
74				parent.parentNode.selectedIndex;
75			}
76			return null;
77		}
78	};
79}
80
81jQuery.each([
82	"tabIndex",
83	"readOnly",
84	"maxLength",
85	"cellSpacing",
86	"cellPadding",
87	"rowSpan",
88	"colSpan",
89	"useMap",
90	"frameBorder",
91	"contentEditable"
92], function() {
93	jQuery.propFix[ this.toLowerCase() ] = this;
94});
95
96});