File tree 2 files changed +12
-11
lines changed
2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,14 @@ function stripHtmlToText(html)
57
57
res = res . replace ( / \n / , "" ) ;
58
58
return res . trim ( ) ;
59
59
}
60
+ // get html
61
+ function getDomFromHtml ( html )
62
+ {
63
+ var tmp = document . createElement ( "DIV" ) ;
64
+ tmp . innerHTML = html ;
65
+ return tmp ;
66
+ }
67
+
60
68
61
69
// Global to textAngular REGEXP vars for block and list elements.
62
70
Original file line number Diff line number Diff line change @@ -403,17 +403,10 @@ textAngular.directive("textAngular", [
403
403
_model = scope . html ;
404
404
}
405
405
var _html = scope . displayElements . html [ 0 ] . value ;
406
- // find first non-tag match - ie start of string or after tag that is not whitespace
407
- var _firstMatchModel = / ( ^ [ ^ < ] | > ) [ ^ < ] / i. exec ( _model ) ;
408
- var _firstMatchHtml = / ( ^ [ ^ < ] | > ) [ ^ < ] / i. exec ( _html ) ;
409
- if ( _firstMatchHtml && _firstMatchModel ) {
410
- if ( ( _firstMatchHtml . index !== _firstMatchModel . index ) ) {
411
- // the model and the html do not agree
412
- // they can get out of sync and when they do, we correct that here...
413
- //console.log('model', _firstMatchModel, _model);
414
- //console.log('html', _firstMatchHtml, _html);
415
- scope . displayElements . html . val ( _model ) ;
416
- }
406
+ if ( getDomFromHtml ( _html ) . childElementCount !== getDomFromHtml ( _model ) . childElementCount ) {
407
+ // the model and the html do not agree
408
+ // they can get out of sync and when they do, we correct that here...
409
+ scope . displayElements . html . val ( _model ) ;
417
410
}
418
411
if ( scope . showHtml ) {
419
412
//defer until the element is visible
You can’t perform that action at this time.
0 commit comments