@@ 7092-7163 (lines=72) @@ | ||
7089 | }, |
|
7090 | ||
7091 | // Get and set the style property on a DOM Node |
|
7092 | style: function( elem, name, value, extra ) { |
|
7093 | ||
7094 | // Don't set styles on text and comment nodes |
|
7095 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
|
7096 | return; |
|
7097 | } |
|
7098 | ||
7099 | // Make sure that we're working with the right name |
|
7100 | var ret, type, hooks, |
|
7101 | origName = jQuery.camelCase( name ), |
|
7102 | style = elem.style; |
|
7103 | ||
7104 | name = jQuery.cssProps[ origName ] || |
|
7105 | ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); |
|
7106 | ||
7107 | // gets hook for the prefixed version |
|
7108 | // followed by the unprefixed version |
|
7109 | hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
7110 | ||
7111 | // Check if we're setting a value |
|
7112 | if ( value !== undefined ) { |
|
7113 | type = typeof value; |
|
7114 | ||
7115 | // Convert "+=" or "-=" to relative numbers (#7345) |
|
7116 | if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { |
|
7117 | value = adjustCSS( elem, name, ret ); |
|
7118 | ||
7119 | // Fixes bug #9237 |
|
7120 | type = "number"; |
|
7121 | } |
|
7122 | ||
7123 | // Make sure that null and NaN values aren't set. See: #7116 |
|
7124 | if ( value == null || value !== value ) { |
|
7125 | return; |
|
7126 | } |
|
7127 | ||
7128 | // If a number was passed in, add the unit (except for certain CSS properties) |
|
7129 | if ( type === "number" ) { |
|
7130 | value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); |
|
7131 | } |
|
7132 | ||
7133 | // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, |
|
7134 | // but it would mean to define eight |
|
7135 | // (for every problematic property) identical functions |
|
7136 | if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { |
|
7137 | style[ name ] = "inherit"; |
|
7138 | } |
|
7139 | ||
7140 | // If a hook was provided, use that value, otherwise just set the specified value |
|
7141 | if ( !hooks || !( "set" in hooks ) || |
|
7142 | ( value = hooks.set( elem, value, extra ) ) !== undefined ) { |
|
7143 | ||
7144 | // Support: IE |
|
7145 | // Swallow errors from 'invalid' CSS values (#5509) |
|
7146 | try { |
|
7147 | style[ name ] = value; |
|
7148 | } catch ( e ) {} |
|
7149 | } |
|
7150 | ||
7151 | } else { |
|
7152 | ||
7153 | // If a hook was provided get the non-computed value from there |
|
7154 | if ( hooks && "get" in hooks && |
|
7155 | ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { |
|
7156 | ||
7157 | return ret; |
|
7158 | } |
|
7159 | ||
7160 | // Otherwise just get the value from the style object |
|
7161 | return style[ name ]; |
|
7162 | } |
|
7163 | }, |
|
7164 | ||
7165 | css: function( elem, name, extra, styles ) { |
|
7166 | var num, val, hooks, |
@@ 6110-6175 (lines=66) @@ | ||
6107 | }, |
|
6108 | ||
6109 | // Get and set the style property on a DOM Node |
|
6110 | style: function( elem, name, value, extra ) { |
|
6111 | ||
6112 | // Don't set styles on text and comment nodes |
|
6113 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
|
6114 | return; |
|
6115 | } |
|
6116 | ||
6117 | // Make sure that we're working with the right name |
|
6118 | var ret, type, hooks, |
|
6119 | origName = jQuery.camelCase( name ), |
|
6120 | style = elem.style; |
|
6121 | ||
6122 | name = jQuery.cssProps[ origName ] || |
|
6123 | ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); |
|
6124 | ||
6125 | // Gets hook for the prefixed version, then unprefixed version |
|
6126 | hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
6127 | ||
6128 | // Check if we're setting a value |
|
6129 | if ( value !== undefined ) { |
|
6130 | type = typeof value; |
|
6131 | ||
6132 | // Convert "+=" or "-=" to relative numbers (#7345) |
|
6133 | if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { |
|
6134 | value = adjustCSS( elem, name, ret ); |
|
6135 | ||
6136 | // Fixes bug #9237 |
|
6137 | type = "number"; |
|
6138 | } |
|
6139 | ||
6140 | // Make sure that null and NaN values aren't set (#7116) |
|
6141 | if ( value == null || value !== value ) { |
|
6142 | return; |
|
6143 | } |
|
6144 | ||
6145 | // If a number was passed in, add the unit (except for certain CSS properties) |
|
6146 | if ( type === "number" ) { |
|
6147 | value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); |
|
6148 | } |
|
6149 | ||
6150 | // Support: IE9-11+ |
|
6151 | // background-* props affect original clone's values |
|
6152 | if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { |
|
6153 | style[ name ] = "inherit"; |
|
6154 | } |
|
6155 | ||
6156 | // If a hook was provided, use that value, otherwise just set the specified value |
|
6157 | if ( !hooks || !( "set" in hooks ) || |
|
6158 | ( value = hooks.set( elem, value, extra ) ) !== undefined ) { |
|
6159 | ||
6160 | style[ name ] = value; |
|
6161 | } |
|
6162 | ||
6163 | } else { |
|
6164 | ||
6165 | // If a hook was provided get the non-computed value from there |
|
6166 | if ( hooks && "get" in hooks && |
|
6167 | ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { |
|
6168 | ||
6169 | return ret; |
|
6170 | } |
|
6171 | ||
6172 | // Otherwise just get the value from the style object |
|
6173 | return style[ name ]; |
|
6174 | } |
|
6175 | }, |
|
6176 | ||
6177 | css: function( elem, name, extra, styles ) { |
|
6178 | var val, num, hooks, |