Skip to content

Commit

Permalink
perf: improve value handling for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Oct 3, 2017
1 parent da7d0c7 commit 8695873
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/app/ngx-editor/ngx-editor.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<button (click)="executeCommand('insertOrderedList')" title="Ordered List"><i class="fa fa-list-ol" aria-hidden="true"></i></button>
</div>
</div>
<div class="textarea" [attr.contenteditable]="editable || config['editable']" [attr.placeholder]="placeholder || config['placeholder']"
<div class="textarea" [attr.contenteditable]="getBooleanProperty('editable')" [attr.placeholder]="placeholder || config['placeholder']"
(input)="html = $event.target.innerHTML; htmlContentChange($event.target.innerHTML)" [attr.translate]="translate || config['translate']"
[attr.spellcheck]="config['spellcheck']"></div>
[attr.spellcheck]="getBooleanProperty('spellcheck')"></div>
</div>
19 changes: 12 additions & 7 deletions src/app/ngx-editor/ngx-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,22 @@ export class NgxEditorComponent implements OnInit {
}

/*
* ngOnInit
* return values for attributes that accepts boolean
*/
ngOnInit() {
if (this.spellcheck === false) {
this.config['spellcheck'] = false;
getBooleanProperty(value) {
if (this[value] === false) {
return false;
}

if (this.editable === false) {
this.config['editable'] = false;
if (this[value] === undefined) {
return this.config[value];
}
return true;
}

/*
* ngOnInit
*/
ngOnInit() {
this.element.nativeElement.getElementsByClassName('textarea')[0].innerHTML = this.html || '';
}

Expand Down

0 comments on commit 8695873

Please sign in to comment.