@@ -30,16 +30,19 @@ window.ShadowDOMPolyfill = {};
30
30
throw new Error ( 'Assertion failed' ) ;
31
31
} ;
32
32
33
+ var defineProperty = Object . defineProperty ;
34
+ var getOwnPropertyNames = Object . getOwnPropertyNames ;
35
+ var getOwnPropertyDescriptor = Object . getOwnPropertyDescriptor ;
36
+
33
37
function mixin ( to , from ) {
34
- Object . getOwnPropertyNames ( from ) . forEach ( function ( name ) {
35
- Object . defineProperty ( to , name ,
36
- Object . getOwnPropertyDescriptor ( from , name ) ) ;
38
+ getOwnPropertyNames ( from ) . forEach ( function ( name ) {
39
+ defineProperty ( to , name , getOwnPropertyDescriptor ( from , name ) ) ;
37
40
} ) ;
38
41
return to ;
39
42
} ;
40
43
41
44
function mixinStatics ( to , from ) {
42
- Object . getOwnPropertyNames ( from ) . forEach ( function ( name ) {
45
+ getOwnPropertyNames ( from ) . forEach ( function ( name ) {
43
46
switch ( name ) {
44
47
case 'arguments' :
45
48
case 'caller' :
@@ -49,8 +52,7 @@ window.ShadowDOMPolyfill = {};
49
52
case 'toString' :
50
53
return ;
51
54
}
52
- Object . defineProperty ( to , name ,
53
- Object . getOwnPropertyDescriptor ( from , name ) ) ;
55
+ defineProperty ( to , name , getOwnPropertyDescriptor ( from , name ) ) ;
54
56
} ) ;
55
57
return to ;
56
58
} ;
@@ -65,7 +67,7 @@ window.ShadowDOMPolyfill = {};
65
67
// Mozilla's old DOM bindings are bretty busted:
66
68
// https://bugzilla.mozilla.org/show_bug.cgi?id=855844
67
69
// Make sure they are create before we start modifying things.
68
- Object . getOwnPropertyNames ( window ) ;
70
+ getOwnPropertyNames ( window ) ;
69
71
70
72
function getWrapperConstructor ( node ) {
71
73
var nativePrototype = node . __proto__ || Object . getPrototypeOf ( node ) ;
@@ -128,7 +130,7 @@ window.ShadowDOMPolyfill = {};
128
130
}
129
131
130
132
function installProperty ( source , target , allowMethod ) {
131
- Object . getOwnPropertyNames ( source ) . forEach ( function ( name ) {
133
+ getOwnPropertyNames ( source ) . forEach ( function ( name ) {
132
134
if ( name in target )
133
135
return ;
134
136
@@ -138,7 +140,7 @@ window.ShadowDOMPolyfill = {};
138
140
}
139
141
var descriptor ;
140
142
try {
141
- descriptor = Object . getOwnPropertyDescriptor ( source , name ) ;
143
+ descriptor = getOwnPropertyDescriptor ( source , name ) ;
142
144
} catch ( ex ) {
143
145
// JSC and V8 both use data properties instead of accessors which can
144
146
// cause getting the property desciptor to throw an exception.
@@ -164,7 +166,7 @@ window.ShadowDOMPolyfill = {};
164
166
setter = getSetter ( name ) ;
165
167
}
166
168
167
- Object . defineProperty ( target , name , {
169
+ defineProperty ( target , name , {
168
170
get : getter ,
169
171
set : setter ,
170
172
configurable : descriptor . configurable ,
@@ -195,6 +197,12 @@ window.ShadowDOMPolyfill = {};
195
197
addForwardingProperties ( nativePrototype , wrapperPrototype ) ;
196
198
if ( opt_instance )
197
199
registerInstanceProperties ( wrapperPrototype , opt_instance ) ;
200
+ defineProperty ( wrapperPrototype , 'constructor' , {
201
+ value : wrapperConstructor ,
202
+ configurable : true ,
203
+ enumerable : false ,
204
+ writable : true
205
+ } ) ;
198
206
}
199
207
200
208
function isWrapperFor ( wrapperConstructor , nativeConstructor ) {
@@ -205,11 +213,7 @@ window.ShadowDOMPolyfill = {};
205
213
/**
206
214
* Creates a generic wrapper constructor based on |object| and its
207
215
* constructor.
208
- * Sometimes the constructor does not have an associated instance
209
- * (CharacterData for example). In that case you can pass the constructor that
210
- * you want to map the object to using |opt_nativeConstructor|.
211
216
* @param {Node } object
212
- * @param {Function= } opt_nativeConstructor
213
217
* @return {Function } The generated constructor.
214
218
*/
215
219
function registerObject ( object ) {
@@ -322,7 +326,7 @@ window.ShadowDOMPolyfill = {};
322
326
}
323
327
324
328
function defineGetter ( constructor , name , getter ) {
325
- Object . defineProperty ( constructor . prototype , name , {
329
+ defineProperty ( constructor . prototype , name , {
326
330
get : getter ,
327
331
configurable : true ,
328
332
enumerable : true
0 commit comments