@@ -1038,109 +1038,115 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure
10381038 return CollectionLengthObserver ;
10391039 } ( ) ) || _class3 ) ;
10401040
1041- var pop = Array . prototype . pop ;
1042- var push = Array . prototype . push ;
1043- var reverse = Array . prototype . reverse ;
1044- var shift = Array . prototype . shift ;
1045- var sort = Array . prototype . sort ;
1046- var splice = Array . prototype . splice ;
1047- var unshift = Array . prototype . unshift ;
1048-
1049- Array . prototype . pop = function ( ) {
1050- var notEmpty = this . length > 0 ;
1051- var methodCallResult = pop . apply ( this , arguments ) ;
1052- if ( notEmpty && this . __array_observer__ !== undefined ) {
1053- this . __array_observer__ . addChangeRecord ( {
1054- type : 'delete' ,
1055- object : this ,
1056- name : this . length ,
1057- oldValue : methodCallResult
1058- } ) ;
1059- }
1060- return methodCallResult ;
1061- } ;
1041+ var arrayProto = Array . prototype ;
1042+ var pop = arrayProto . pop ;
1043+ var push = arrayProto . push ;
1044+ var reverse = arrayProto . reverse ;
1045+ var shift = arrayProto . shift ;
1046+ var sort = arrayProto . sort ;
1047+ var splice = arrayProto . splice ;
1048+ var unshift = arrayProto . unshift ;
1049+
1050+ if ( arrayProto . __au_patched__ ) {
1051+ LogManager . getLogger ( 'array-observation' ) . warn ( 'Detected 2nd attempt of patching array from Aurelia binding.' + ' This is probably caused by dependency mismatch between core modules and a 3rd party plugin.' + ' Please see https://github.com/aurelia/cli/pull/906 if you are using webpack.' ) ;
1052+ } else {
1053+ arrayProto . __au_patched__ = 1 ;
1054+ arrayProto . pop = function ( ) {
1055+ var notEmpty = this . length > 0 ;
1056+ var methodCallResult = pop . apply ( this , arguments ) ;
1057+ if ( notEmpty && this . __array_observer__ !== undefined ) {
1058+ this . __array_observer__ . addChangeRecord ( {
1059+ type : 'delete' ,
1060+ object : this ,
1061+ name : this . length ,
1062+ oldValue : methodCallResult
1063+ } ) ;
1064+ }
1065+ return methodCallResult ;
1066+ } ;
10621067
1063- Array . prototype . push = function ( ) {
1064- var methodCallResult = push . apply ( this , arguments ) ;
1065- if ( this . __array_observer__ !== undefined ) {
1066- this . __array_observer__ . addChangeRecord ( {
1067- type : 'splice' ,
1068- object : this ,
1069- index : this . length - arguments . length ,
1070- removed : [ ] ,
1071- addedCount : arguments . length
1072- } ) ;
1073- }
1074- return methodCallResult ;
1075- } ;
1068+ arrayProto . push = function ( ) {
1069+ var methodCallResult = push . apply ( this , arguments ) ;
1070+ if ( this . __array_observer__ !== undefined ) {
1071+ this . __array_observer__ . addChangeRecord ( {
1072+ type : 'splice' ,
1073+ object : this ,
1074+ index : this . length - arguments . length ,
1075+ removed : [ ] ,
1076+ addedCount : arguments . length
1077+ } ) ;
1078+ }
1079+ return methodCallResult ;
1080+ } ;
10761081
1077- Array . prototype . reverse = function ( ) {
1078- var oldArray = void 0 ;
1079- if ( this . __array_observer__ !== undefined ) {
1080- this . __array_observer__ . flushChangeRecords ( ) ;
1081- oldArray = this . slice ( ) ;
1082- }
1083- var methodCallResult = reverse . apply ( this , arguments ) ;
1084- if ( this . __array_observer__ !== undefined ) {
1085- this . __array_observer__ . reset ( oldArray ) ;
1086- }
1087- return methodCallResult ;
1088- } ;
1082+ arrayProto . reverse = function ( ) {
1083+ var oldArray = void 0 ;
1084+ if ( this . __array_observer__ !== undefined ) {
1085+ this . __array_observer__ . flushChangeRecords ( ) ;
1086+ oldArray = this . slice ( ) ;
1087+ }
1088+ var methodCallResult = reverse . apply ( this , arguments ) ;
1089+ if ( this . __array_observer__ !== undefined ) {
1090+ this . __array_observer__ . reset ( oldArray ) ;
1091+ }
1092+ return methodCallResult ;
1093+ } ;
10891094
1090- Array . prototype . shift = function ( ) {
1091- var notEmpty = this . length > 0 ;
1092- var methodCallResult = shift . apply ( this , arguments ) ;
1093- if ( notEmpty && this . __array_observer__ !== undefined ) {
1094- this . __array_observer__ . addChangeRecord ( {
1095- type : 'delete' ,
1096- object : this ,
1097- name : 0 ,
1098- oldValue : methodCallResult
1099- } ) ;
1100- }
1101- return methodCallResult ;
1102- } ;
1095+ arrayProto . shift = function ( ) {
1096+ var notEmpty = this . length > 0 ;
1097+ var methodCallResult = shift . apply ( this , arguments ) ;
1098+ if ( notEmpty && this . __array_observer__ !== undefined ) {
1099+ this . __array_observer__ . addChangeRecord ( {
1100+ type : 'delete' ,
1101+ object : this ,
1102+ name : 0 ,
1103+ oldValue : methodCallResult
1104+ } ) ;
1105+ }
1106+ return methodCallResult ;
1107+ } ;
11031108
1104- Array . prototype . sort = function ( ) {
1105- var oldArray = void 0 ;
1106- if ( this . __array_observer__ !== undefined ) {
1107- this . __array_observer__ . flushChangeRecords ( ) ;
1108- oldArray = this . slice ( ) ;
1109- }
1110- var methodCallResult = sort . apply ( this , arguments ) ;
1111- if ( this . __array_observer__ !== undefined ) {
1112- this . __array_observer__ . reset ( oldArray ) ;
1113- }
1114- return methodCallResult ;
1115- } ;
1109+ arrayProto . sort = function ( ) {
1110+ var oldArray = void 0 ;
1111+ if ( this . __array_observer__ !== undefined ) {
1112+ this . __array_observer__ . flushChangeRecords ( ) ;
1113+ oldArray = this . slice ( ) ;
1114+ }
1115+ var methodCallResult = sort . apply ( this , arguments ) ;
1116+ if ( this . __array_observer__ !== undefined ) {
1117+ this . __array_observer__ . reset ( oldArray ) ;
1118+ }
1119+ return methodCallResult ;
1120+ } ;
11161121
1117- Array . prototype . splice = function ( ) {
1118- var methodCallResult = splice . apply ( this , arguments ) ;
1119- if ( this . __array_observer__ !== undefined ) {
1120- this . __array_observer__ . addChangeRecord ( {
1121- type : 'splice' ,
1122- object : this ,
1123- index : + arguments [ 0 ] ,
1124- removed : methodCallResult ,
1125- addedCount : arguments . length > 2 ? arguments . length - 2 : 0
1126- } ) ;
1127- }
1128- return methodCallResult ;
1129- } ;
1122+ arrayProto . splice = function ( ) {
1123+ var methodCallResult = splice . apply ( this , arguments ) ;
1124+ if ( this . __array_observer__ !== undefined ) {
1125+ this . __array_observer__ . addChangeRecord ( {
1126+ type : 'splice' ,
1127+ object : this ,
1128+ index : + arguments [ 0 ] ,
1129+ removed : methodCallResult ,
1130+ addedCount : arguments . length > 2 ? arguments . length - 2 : 0
1131+ } ) ;
1132+ }
1133+ return methodCallResult ;
1134+ } ;
11301135
1131- Array . prototype . unshift = function ( ) {
1132- var methodCallResult = unshift . apply ( this , arguments ) ;
1133- if ( this . __array_observer__ !== undefined ) {
1134- this . __array_observer__ . addChangeRecord ( {
1135- type : 'splice' ,
1136- object : this ,
1137- index : 0 ,
1138- removed : [ ] ,
1139- addedCount : arguments . length
1140- } ) ;
1141- }
1142- return methodCallResult ;
1143- } ;
1136+ arrayProto . unshift = function ( ) {
1137+ var methodCallResult = unshift . apply ( this , arguments ) ;
1138+ if ( this . __array_observer__ !== undefined ) {
1139+ this . __array_observer__ . addChangeRecord ( {
1140+ type : 'splice' ,
1141+ object : this ,
1142+ index : 0 ,
1143+ removed : [ ] ,
1144+ addedCount : arguments . length
1145+ } ) ;
1146+ }
1147+ return methodCallResult ;
1148+ } ;
1149+ }
11441150
11451151 function _getArrayObserver ( taskQueue , array ) {
11461152 return ModifyArrayObserver . for ( taskQueue , array ) ;
0 commit comments