Skip to content

Commit 080ce7e

Browse files
committed
fix(facade): fix issues with global resolution by providing custom assign
1 parent 5c5be30 commit 080ce7e

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

src/directives.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import angular from './facade';
1+
import { assign } from './facade';
22
import {hasInjectables,makeSelector,firstLowerCase,is} from './util';
33

44
import {getLifecycleMethod,LifecycleHooks} from './life_cycle';
@@ -118,7 +118,7 @@ export function Component(
118118
if ( attrs || inputs || outputs ) {
119119

120120
const {attr,input,output} = _createBindings( { inputs, attrs, outputs } );
121-
ddoInternal.bindToController = angular.extend( {}, ddoInternal.bindToController, attr, input, output );
121+
ddoInternal.bindToController = assign( {}, ddoInternal.bindToController, attr, input, output );
122122

123123
}
124124
if ( legacy.require ) {
@@ -178,7 +178,7 @@ function _propertyDecoratorFactoryCreator( bindingPropertyName: string, property
178178
const binding = _createBindings( { [`${propertyType}s`]: format } )[ propertyType ];
179179

180180
if ( existingBindings ) {
181-
angular.extend( existingBindings, binding );
181+
assign( existingBindings, binding );
182182
} else {
183183
Type[ DDO_NAME ] = { bindToController: binding };
184184
}
@@ -201,13 +201,13 @@ function _getTypeBindings( Type ): {} {
201201
}
202202
function _decorateDirectiveType( Type, selector, legacy, ddoCreator: Function ) {
203203
const ddo = ddoCreator( Type );
204-
const _ddo = angular.extend( {}, ddo, legacy );
204+
const _ddo = assign( {}, ddo, legacy );
205205
const staticConfig: DirectiveConfigStatic = {
206206
selector,
207207
_ddo
208208
};
209209

210-
angular.extend( Type, staticConfig );
210+
assign( Type, staticConfig );
211211
}
212212

213213
function _postLinkFactory( isDirective: boolean ) {

src/facade.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
declare var global;
1+
export function assign( destination: any, ...sources: any[] ): any {
22

3-
const angular = ((win)=> {
3+
const innerAssign = Object[ 'assign' ] || window[ 'angular' ].extend;
44

5-
if ( win ) {
5+
return innerAssign( destination, ...sources );
66

7-
return win[ 'angular' ];
8-
9-
}
10-
11-
// this is for Node
12-
return {
13-
extend: Object[ 'assign' ]
14-
}
15-
16-
})( window );
17-
18-
19-
export default angular;
7+
}

src/pipe.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import angular from './facade';
1+
//import angular from './facade';
22
import {hasInjectables, is} from './util';
3+
import { assign } from "./facade";
4+
5+
//const assign = assignFactory();
36

47
interface PipeFactory {
58
( obj: {name: string, pure?: boolean} ): ClassDecorator;
@@ -48,7 +51,7 @@ export function Pipe(
4851
};
4952

5053
// remove angular and use Object.assign instead
51-
angular.extend( Type, staticConfig );
54+
assign( Type, staticConfig );
5255

5356
}
5457

0 commit comments

Comments
 (0)