Replaced __define[GS]etter__ with defineProperty for prop proxy
parent
3651e31d20
commit
df2943b5a1
|
@ -90,18 +90,23 @@ exports.createPropProxy = function( base, dest, props )
|
||||||
|
|
||||||
( function( prop )
|
( function( prop )
|
||||||
{
|
{
|
||||||
|
// just in case it's already defined, so we don't throw an error
|
||||||
|
dest[ prop ] = undefined;
|
||||||
|
|
||||||
// public properties, when set internally, must forward to the
|
// public properties, when set internally, must forward to the
|
||||||
// actual variable
|
// actual variable
|
||||||
dest.__defineSetter__( prop, function( val )
|
Object.defineProperty( dest, prop, {
|
||||||
|
set: function( val )
|
||||||
{
|
{
|
||||||
base[ prop ] = val;
|
base[ prop ] = val;
|
||||||
} );
|
},
|
||||||
|
|
||||||
// since we're defining a setter, we'll need to define a getter
|
get: function()
|
||||||
// to return the value, or we'll simply return undefined
|
|
||||||
dest.__defineGetter__( prop, function()
|
|
||||||
{
|
{
|
||||||
return base[ prop ];
|
return base[ prop ];
|
||||||
|
},
|
||||||
|
|
||||||
|
enumerable: true,
|
||||||
} );
|
} );
|
||||||
} ).call( null, prop );
|
} ).call( null, prop );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue