From b666fa1708083705ca3d8f5c780451864f271579 Mon Sep 17 00:00:00 2001 From: dxvladislavvolkov Date: Tue, 10 Apr 2018 20:14:53 +0300 Subject: [PATCH] Revert "Prevent option change event firing when changes occur in component (#712) (#744) * Revert "Prevent option change event firing when changes occur in component (#712) (#717)" This reverts commit 08a40ba87072923693543daf71efd7008426ebc8. * Update shippable config * Fix tests --- karma.conf.js | 3 +++ karma.systemjs.conf.js | 3 ++- shippable.yml | 2 +- src/core/events-strategy.ts | 4 ---- templates/component.tst | 2 -- ...stom-value-accessor-implementation.spec.ts | 21 ------------------- 6 files changed, 6 insertions(+), 29 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 1300a27d6..53dc15765 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -24,6 +24,9 @@ module.exports = function(config) { // RxJs { pattern: 'node_modules/rxjs/**/*.+(js|js.map)', included: false, watched: false }, + // tslib + { pattern: 'node_modules/tslib/tslib.js', included: false, watched: false }, + // Angular 2 itself and the testing library { pattern: 'node_modules/@angular/!(compiler-cli|tsc-wrapped)/**/*.+(js|js.map)', included: false, watched: false }, diff --git a/karma.systemjs.conf.js b/karma.systemjs.conf.js index f1561c95b..b4a225ae2 100644 --- a/karma.systemjs.conf.js +++ b/karma.systemjs.conf.js @@ -30,7 +30,8 @@ // other libraries 'rxjs': 'npm:rxjs', - 'rxjs/operators': 'npm:rxjs/operators/index.js' + 'rxjs/operators': 'npm:rxjs/operators/index.js', + 'tslib': 'npm:tslib/tslib.js' }, packages: { app: { diff --git a/shippable.yml b/shippable.yml index 141a9ff82..e36a521ea 100644 --- a/shippable.yml +++ b/shippable.yml @@ -28,6 +28,6 @@ build: - shippable_retry npm install @angular/core@^5.0.0 @angular/common@^5.0.0 @angular/compiler@^5.0.0 @angular/compiler-cli@^5.0.0 @angular/forms@^5.0.0 @angular/http@^5.0.0 @angular/platform-browser@^5.0.0 @angular/platform-browser-dynamic@^5.0.0 --unsafe-perm - gulp build.tests - gulp run.tests - - shippable_retry npm install rxjs@^6.0.0-0 @angular/core@^6.0.0-0 @angular/common@^6.0.0-0 @angular/compiler@^6.0.0-0 @angular/compiler-cli@^6.0.0-0 @angular/forms@^6.0.0-0 @angular/http@^6.0.0-0 @angular/platform-browser@^6.0.0-0 @angular/platform-browser-dynamic@^6.0.0-0 --unsafe-perm + - shippable_retry npm install rxjs@^6.0.0-0 @angular/animations@^6.0.0-0 @angular/core@^6.0.0-0 @angular/common@^6.0.0-0 @angular/compiler@^6.0.0-0 @angular/forms@^6.0.0-0 @angular/http@^6.0.0-0 @angular/platform-browser@^6.0.0-0 @angular/platform-browser-dynamic@^6.0.0-0 @angular/compiler-cli@^6.0.0-0 --unsafe-perm - gulp build.tests - gulp run.tests diff --git a/src/core/events-strategy.ts b/src/core/events-strategy.ts index d2050c062..e557be18e 100644 --- a/src/core/events-strategy.ts +++ b/src/core/events-strategy.ts @@ -93,16 +93,12 @@ let createOnStableSubscription = function(ngZone: NgZone, fireNgEvent: Function) export class EmitterHelper { strategy: NgEventsStrategy; - lockedValueChangeEvent = false; constructor(ngZone: NgZone, public component: DxComponent) { this.strategy = new NgEventsStrategy(component, ngZone); createOnStableSubscription(ngZone, this.fireNgEvent); } fireNgEvent(eventName: string, eventArgs: any) { - if (this.lockedValueChangeEvent && eventName === 'valueChange') { - return; - } let emitter = this.component[eventName]; if (emitter) { emitter.next(eventArgs && eventArgs[0]); diff --git a/templates/component.tst b/templates/component.tst index 11702bb25..82c2b660b 100644 --- a/templates/component.tst +++ b/templates/component.tst @@ -139,9 +139,7 @@ export class <#= it.className #>Component extends <#= baseClass #> <#? implement } <#? it.isEditor #> writeValue(value: any): void { - this.eventHelper.lockedValueChangeEvent = true; this.value = value; - this.eventHelper.lockedValueChangeEvent = false; } <#? it.widgetName !== "dxRangeSelector" #> setDisabledState(isDisabled: boolean): void { diff --git a/tests/src/ui/custom-value-accessor-implementation.spec.ts b/tests/src/ui/custom-value-accessor-implementation.spec.ts index ad9bfd8f0..b02981ee5 100644 --- a/tests/src/ui/custom-value-accessor-implementation.spec.ts +++ b/tests/src/ui/custom-value-accessor-implementation.spec.ts @@ -78,7 +78,6 @@ describe('DxTextBox value accessor', () => { expect(instance.option('disabled')).toBe(false); })); - it('should change the value', async(() => { let fixture = TestBed.createComponent(TestContainerComponent); fixture.detectChanges(); @@ -90,7 +89,6 @@ describe('DxTextBox value accessor', () => { expect(instance.option('value')).toBe('text'); })); - it('should change touched option', async(() => { let fixture = TestBed.createComponent(TestContainerComponent); fixture.detectChanges(); @@ -104,23 +102,4 @@ describe('DxTextBox value accessor', () => { expect(fixture.componentInstance.formControl.touched).toBe(true); })); - - it('should not fire valueChanges event when patchValue method is used with emitEvent=false (T614207)', () => { - let fixture = TestBed.createComponent(TestContainerComponent); - fixture.detectChanges(); - - let component = fixture.componentInstance, - form = component.form, - testSpy = jasmine.createSpy('testSpy'); - - form.valueChanges.subscribe(testSpy); - - form.controls['formControl'].patchValue('text', { emitEvent: false }); - fixture.detectChanges(); - expect(testSpy).toHaveBeenCalledTimes(0); - - form.controls['formControl'].patchValue('text2'); - fixture.detectChanges(); - expect(testSpy).toHaveBeenCalledTimes(1); - }); });