File tree Expand file tree Collapse file tree 3 files changed +29
-18
lines changed
src/com/google/javascript/jscomp Expand file tree Collapse file tree 3 files changed +29
-18
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,18 @@ $jscomp.polyfill('WeakMap', function(NativeWeakMap) {
2727 */
2828 function isConformant ( ) {
2929 if ( ! NativeWeakMap || ! Object . seal ) return false ;
30- var x = Object . seal ( { } ) ;
31- var y = Object . seal ( { } ) ;
32- var map = new /** @type {function(new: WeakMap, !Array) } */ ( NativeWeakMap ) (
33- [ [ x , 2 ] , [ y , 3 ] ] ) ;
34- if ( map . get ( x ) != 2 || map . get ( y ) != 3 ) return false ;
35- map . delete ( x ) ;
36- map . set ( y , 4 ) ;
37- return ! map . has ( x ) && map . get ( y ) == 4 ;
30+ try {
31+ var x = Object . seal ( { } ) ;
32+ var y = Object . seal ( { } ) ;
33+ var map = new /** @type {function(new: WeakMap, !Array) } */ (
34+ NativeWeakMap ) ( [ [ x , 2 ] , [ y , 3 ] ] ) ;
35+ if ( map . get ( x ) != 2 || map . get ( y ) != 3 ) return false ;
36+ map . delete ( x ) ;
37+ map . set ( y , 4 ) ;
38+ return ! map . has ( x ) && map . get ( y ) == 4 ;
39+ } catch ( err ) { // This should hopefully never happen, but let's be safe.
40+ return false ;
41+ }
3842 }
3943 if ( isConformant ( ) ) return NativeWeakMap ;
4044
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- 'require es6/symbol es6/util/makeiterator util/polyfill es6/weakmap' ;
17+ 'require es6/symbol' ;
18+ 'require es6/util/makeiterator' ;
19+ 'require util/polyfill' ;
20+ 'require es6/weakmap' ;
1821
1922$jscomp . polyfill ( 'WeakSet' , function ( NativeWeakSet ) {
2023 /**
@@ -23,14 +26,18 @@ $jscomp.polyfill('WeakSet', function(NativeWeakSet) {
2326 */
2427 function isConformant ( ) {
2528 if ( ! NativeWeakSet || ! Object . seal ) return false ;
26- var x = Object . seal ( { } ) ;
27- var y = Object . seal ( { } ) ;
28- var set = new /** @type {function(new: WeakSet, !Array) } */ ( NativeWeakSet ) (
29- [ x ] ) ;
30- if ( ! set . has ( x ) || set . has ( y ) ) return false ;
31- set . delete ( x ) ;
32- set . add ( y ) ;
33- return ! set . has ( x ) && set . has ( y ) ;
29+ try {
30+ var x = Object . seal ( { } ) ;
31+ var y = Object . seal ( { } ) ;
32+ var set = new /** @type {function(new: WeakSet, !Array) } */ (
33+ NativeWeakSet ) ( [ x ] ) ;
34+ if ( ! set . has ( x ) || set . has ( y ) ) return false ;
35+ set . delete ( x ) ;
36+ set . add ( y ) ;
37+ return ! set . has ( x ) && set . has ( y ) ;
38+ } catch ( err ) { // This should hopefully never happen, but let's be safe.
39+ return false ;
40+ }
3441 }
3542 if ( isConformant ( ) ) return NativeWeakSet ;
3643
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments