Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Fixed text highlight to not fire when attributes are changed on the d…
Browse files Browse the repository at this point in the history
…irective. (#15)
  • Loading branch information
Blackbaud-AlexKingman authored and Blackbaud-SteveBrush committed Nov 12, 2018
1 parent 0c4e861 commit 4c938f3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Component, ViewChild } from '@angular/core';
import { SkyTextHighlightDirective } from '../text-highlight.directive';

@Component({
selector: 'sky-text-highlight-component',
Expand All @@ -10,4 +11,7 @@ export class SkyTextHighlightTestComponent {
public showAdditionalContent: boolean = false;
public innerText1: string = 'Here is some test text.';
public innerText2: string = 'Here is additional text that was previously hidden in src\\app.';

@ViewChild(SkyTextHighlightDirective)
public textHighlightDirective: SkyTextHighlightDirective;
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ describe('Text Highlight', () => {
});
}));

it('highlight should NOT be called when DOM attributes are changed', ((done) => {
const spy = spyOn<any>(component.textHighlightDirective, 'highlight').and.callThrough();

updateInputText(fixture, 'text');

const div = nativeElement.querySelector('.sky-test-div-container');
div.setAttribute('foo', 'bar');
fixture.detectChanges();

window.setTimeout(() => {
expect(spy).toHaveBeenCalledTimes(1);
done();
});
}));

it('should highlight case insensitive search term', () => {
updateInputText(fixture, 'here');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class SkyTextHighlightDirective

private observeDom() {
if (this.observer) {
const config = { attributes: true, childList: true, characterData: true };
const config = { attributes: false, childList: true, characterData: true };
this.observer.observe(this.el.nativeElement, config);
}
}
Expand Down

0 comments on commit 4c938f3

Please sign in to comment.