Skip to content

Commit

Permalink
Fix(main): Corrected issues with html and model getting out of synch!
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelParke committed Jul 30, 2016
1 parent 31cf9c4 commit 91fe5bf
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,26 @@ textAngular.directive("textAngular", [
$animate.enabled(false, scope.displayElements.html);
$animate.enabled(false, scope.displayElements.text);
//Show the HTML view
/* var _model;
var _model;
/* istanbul ignore next: ngModel exists check */
if (attrs.ngModell) {
_model = ngModel.$viewValue;
} else {
_model = scope.html;
}
var _html = scope.displayElements.html[0].value;
console.log('model', _model);
console.log('html', _html);
*/
// find first non-tag match - ie start of string or after tag that is not whitespace
var _firstMatchModel = /(^[^<]|>)[^<]/i.exec(_model);
var _firstMatchHtml = /(^[^<]|>)[^<]/i.exec(_html);
if (_firstMatchHtml && _firstMatchModel) {
if ((_firstMatchHtml.index !== _firstMatchModel.index)) {
// the model and the html do not agree
// they can get out of sync and when they do, we correct that here...
//console.log('model', _firstMatchModel, _model);
//console.log('html', _firstMatchHtml, _html);
scope.displayElements.html.val(_model);
}
}
if(scope.showHtml){
//defer until the element is visible
$timeout(function(){
Expand Down

0 comments on commit 91fe5bf

Please sign in to comment.