1 import { jQuery } from "../core.js";
2 import { access } from "../core/access.js";
3 import { isIE } from "../var/isIE.js";
5 var rfocusable = /^(?:input|select|textarea|button)$/i,
6 rclickable = /^(?:a|area)$/i;
9 prop: function( name, value ) {
10 return access( this, jQuery.prop, name, value, arguments.length > 1 );
13 removeProp: function( name ) {
14 return this.each( function() {
15 delete this[ jQuery.propFix[ name ] || name ];
21 prop: function( elem, name, value ) {
23 nType = elem.nodeType;
25 // Don't get/set properties on text, comment and attribute nodes
26 if ( nType === 3 || nType === 8 || nType === 2 ) {
30 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
32 // Fix name and attach hooks
33 name = jQuery.propFix[ name ] || name;
34 hooks = jQuery.propHooks[ name ];
37 if ( value !== undefined ) {
38 if ( hooks && "set" in hooks &&
39 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
43 return ( elem[ name ] = value );
46 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
55 get: function( elem ) {
57 // Support: IE <=9 - 11+
58 // elem.tabIndex doesn't always return the
59 // correct value when it hasn't been explicitly set
60 // Use proper attribute retrieval (trac-12072)
61 var tabindex = elem.getAttribute( "tabindex" );
64 return parseInt( tabindex, 10 );
68 rfocusable.test( elem.nodeName ) ||
70 // href-less anchor's `tabIndex` property value is `0` and
71 // the `tabindex` attribute value: `null`. We want `-1`.
72 rclickable.test( elem.nodeName ) && elem.href
89 // Accessing the selectedIndex property forces the browser to respect
90 // setting selected on the option. The getter ensures a default option
91 // is selected when in an optgroup. ESLint rule "no-unused-expressions"
92 // is disabled for this code since it considers such accessions noop.
94 jQuery.propHooks.selected = {
95 get: function( elem ) {
97 var parent = elem.parentNode;
98 if ( parent && parent.parentNode ) {
99 // eslint-disable-next-line no-unused-expressions
100 parent.parentNode.selectedIndex;
104 set: function( elem ) {
107 var parent = elem.parentNode;
109 // eslint-disable-next-line no-unused-expressions
110 parent.selectedIndex;
112 if ( parent.parentNode ) {
113 // eslint-disable-next-line no-unused-expressions
114 parent.parentNode.selectedIndex;
133 jQuery.propFix[ this.toLowerCase() ] = this;