Skip to content
This repository was archived by the owner on Jul 3, 2024. It is now read-only.

Commit 699fb07

Browse files
Trying out an alternative approach to testing for property support in isSupported()
1 parent d225b9b commit 699fb07

File tree

1 file changed

+43
-48
lines changed

1 file changed

+43
-48
lines changed

src/eCSStender.js

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,21 +1226,19 @@ License: MIT License (see homepage)
12261226
}
12271227
function camelize( str )
12281228
{
1229-
var
1230-
bits = str.split(HYPHEN), len = bits.length, new_str, i = 1;
1231-
if ( len == 1 ) { return bits[0]; }
1232-
if ( str.charAt(0) == HYPHEN ) {
1233-
new_str = bits[0].charAt(0).toUpperCase() + bits[0].substring(1);
1234-
} else {
1235-
new_str = bits[0];
1236-
}
1237-
while ( i < len ) {
1238-
new_str += bits[i].charAt(0).toUpperCase() + bits[i].substring(1);
1239-
i++;
1240-
}
1241-
return new_str;
1229+
var
1230+
regex = /(-[a-z])/g,
1231+
func = function( bit ){
1232+
return bit.toUpperCase().replace( HYPHEN, EMPTY );
1233+
};
1234+
camelize = function( str )
1235+
{
1236+
return is( str, STRING ) ? low( str ).replace( regex, func )
1237+
: str;
1238+
};
1239+
return camelize( str );
12421240
}
1243-
function zero_out( str )
1241+
function zero_out( str )
12441242
{
12451243
if ( is( str, STRING ) )
12461244
{
@@ -2081,8 +2079,7 @@ License: MIT License (see homepage)
20812079
html = value,
20822080
el = arg[3] || NULL,
20832081
// property test vars
2084-
property, settable = TRUE, i,
2085-
computed = WINDOW.getComputedStyle,
2082+
property, val, i,
20862083
VISIBILITY = 'visibility',
20872084
HIDDEN = 'hidden',
20882085
// selector test vars
@@ -2106,38 +2103,36 @@ License: MIT License (see homepage)
21062103
{
21072104
// test element
21082105
el = newElement(DIV);
2109-
// are property and value flowing in separately?
2110-
if ( value )
2111-
{
2112-
property = what;
2113-
value = arrayify( value );
2114-
}
2115-
else
2116-
{
2117-
what = what.split(REGEXP_P_V);
2118-
property = what[0];
2119-
value = [ trim( what[1] ) ];
2120-
// reset what for the cache
2121-
what = arg[1];
2122-
}
2123-
__body.appendChild( el );
2124-
toggleExpando();
2125-
if ( ! addInlineStyle( el, property, value[0] ) )
2126-
{
2127-
settable = FALSE;
2128-
}
2129-
toggleExpando();
2130-
if ( settable )
2131-
{
2132-
i = value.length;
2133-
while ( i-- &&
2134-
! result )
2135-
{
2136-
result = ( zero_out( getCSSValue( el, property ) ) == value[i] );
2137-
}
2138-
}
2139-
// cleanup
2140-
__body.removeChild( el );
2106+
// are property and value flowing in separately?
2107+
if ( value )
2108+
{
2109+
property = what;
2110+
value = arrayify( value );
2111+
}
2112+
else
2113+
{
2114+
what = what.split(REGEXP_P_V);
2115+
property = what[0];
2116+
value = [ trim( what[1] ) ];
2117+
// reset what for the cache
2118+
what = arg[1];
2119+
}
2120+
// camel case
2121+
property = camelize( property );
2122+
if ( el.style[property] !== UNDEFINED )
2123+
{
2124+
// set it
2125+
el.style[property] = value[0];
2126+
// get it back
2127+
val = zero_out( el.style[property] );
2128+
// test
2129+
i = value.length;
2130+
while ( i-- &&
2131+
! result )
2132+
{
2133+
result = ( val === value[i] );
2134+
}
2135+
}
21412136
}
21422137
// selector test
21432138
else if ( type == SELECTOR )

0 commit comments

Comments
 (0)