This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +9
-54
lines changed
2 files changed +9
-54
lines changed Original file line number Diff line number Diff line change @@ -749,7 +749,9 @@ function arrayRemove(array, value) {
749
749
return index ;
750
750
}
751
751
752
-
752
+ // A minimal ES6 Map implementation.
753
+ // Should be bug/feature equivelent to the native implementations of supported browsers.
754
+ // See https://kangax.github.io/compat-table/es6/#test-Map
753
755
function ES6MapShim ( ) {
754
756
this . _keys = [ ] ;
755
757
this . _values = [ ] ;
@@ -777,29 +779,15 @@ ES6MapShim.prototype = {
777
779
}
778
780
this . _keys [ idx ] = key ;
779
781
this . _values [ idx ] = value ;
780
- return this ;
782
+
783
+ // Support: IE11
784
+ // Do not `return this` to simulate the partial IE11 implementation
781
785
}
782
786
} ;
783
787
784
- function testES6Map ( Map ) {
785
- var m , o = { } ;
786
- return isFunction ( Map ) && ( m = new Map ( ) )
787
-
788
- // Required functions
789
- && isFunction ( m . get ) && isFunction ( m . set )
790
-
791
- // Number keys, must not call toString
792
- && m . get ( 1 ) === undefined
793
- && m . set ( 1 , o ) === m
794
- && m . get ( 1 ) === o
795
- && m . get ( '1' ) === undefined
796
-
797
- // Object keys, must use instance as key and not call toString
798
- && m . set ( o , 2 ) === m && m . get ( o ) === 2
799
- && m . get ( { } ) === undefined ;
800
- }
801
-
802
- var ES6Map = testES6Map ( window . Map ) ? window . Map : ES6MapShim ;
788
+ var ES6Map = isFunction ( window . Map ) && toString . call ( window . Map . prototype ) === '[object Map]'
789
+ ? window . Map
790
+ : ES6MapShim ;
803
791
804
792
/**
805
793
* @ngdoc function
Original file line number Diff line number Diff line change @@ -25,39 +25,6 @@ describe('angular', function() {
25
25
} ) ;
26
26
} ) ;
27
27
28
- describe ( 'ES6Map' , function ( ) {
29
- it ( 'should test for bad Map objects' , function ( ) {
30
- expect ( testES6Map ( ) ) . toBe ( false ) ;
31
- expect ( testES6Map ( null ) ) . toBe ( false ) ;
32
- expect ( testES6Map ( 3 ) ) . toBe ( false ) ;
33
- expect ( testES6Map ( { } ) ) . toBe ( false ) ;
34
- } ) ;
35
-
36
- it ( 'should test for bad Map shims' , function ( ) {
37
- function NoMethods ( ) { }
38
-
39
- function ToStringOnKeys ( ) {
40
- this . _vals = { } ;
41
- }
42
- ToStringOnKeys . prototype = {
43
- get : function ( key ) {
44
- return this . _vals [ key ] ;
45
- } ,
46
- set : function ( key , val ) {
47
- this . _vals [ key ] = val ;
48
- return this ;
49
- }
50
- } ;
51
-
52
- expect ( testES6Map ( NoMethods ) ) . toBe ( false ) ;
53
- expect ( testES6Map ( ToStringOnKeys ) ) . toBe ( false ) ;
54
- } ) ;
55
-
56
- it ( 'should pass the ES6Map test with ES6MapShim' , function ( ) {
57
- expect ( testES6Map ( ES6MapShim ) ) . toBe ( true ) ;
58
- } ) ;
59
- } ) ;
60
-
61
28
describe ( 'copy' , function ( ) {
62
29
it ( 'should return same object' , function ( ) {
63
30
var obj = { } ;
You can’t perform that action at this time.
0 commit comments