Skip to content

Commit fe800b2

Browse files
SimeonCSimeonC
SimeonC
authored and
SimeonC
committed
fix(taBind._blankTest): Fix a bug where the first tag had really big attributes and cut off the actual content
Fixes #484
1 parent 3d748b0 commit fe800b2

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

dist/textAngular.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/taBind.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
44
return function(_defaultTest){
55
return function(_blankVal){
66
if(!_blankVal) return true;
7-
_blankVal = _blankVal.toString();
7+
// Don't do a global replace as that would be waaayy too long, just replace the first 4 occurences should be enough
8+
_blankVal = _blankVal.toString().replace(/="[^"]*"/i, '').replace(/="[^"]*"/i, '').replace(/="[^"]*"/i, '').replace(/="[^"]*"/i, '');
89
var _firstTagIndex = _blankVal.indexOf('>');
910
if(_firstTagIndex === -1) return _blankVal.trim().length === 0;
1011
_blankVal = _blankVal.trim().substring(_firstTagIndex, _firstTagIndex + 100);

src/textAngular.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,8 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
797797
return function(_defaultTest){
798798
return function(_blankVal){
799799
if(!_blankVal) return true;
800-
_blankVal = _blankVal.toString();
800+
// Don't do a global replace as that would be waaayy too long, just replace the first 4 occurences should be enough
801+
_blankVal = _blankVal.toString().replace(/="[^"]*"/i, '').replace(/="[^"]*"/i, '').replace(/="[^"]*"/i, '').replace(/="[^"]*"/i, '');
801802
var _firstTagIndex = _blankVal.indexOf('>');
802803
if(_firstTagIndex === -1) return _blankVal.trim().length === 0;
803804
_blankVal = _blankVal.trim().substring(_firstTagIndex, _firstTagIndex + 100);

test/taBind/taBind._taBlankTest.spec.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ describe('taBind._taBlankTest', function () {
1919

2020
describe('should return false for', function () {
2121
angular.forEach(
22-
['<p>test</p>','<p>Test Some<br></p>','Some Test','<p><img class="ta-insert-video" src="https://img.youtube.com/vi/sbQQKI1Fwo4/hqdefault.jpg" ta-insert-video="https://www.youtube.com/embed/sbQQKI1Fwo4" contenteditable="false" allowfullscreen="true" frameborder="0"><br></p>'],
22+
[
23+
'<p>test</p>',
24+
'<p>Test Some<br></p>',
25+
'Some Test',
26+
'<p><img class="ta-insert-video" src="https://img.youtube.com/vi/sbQQKI1Fwo4/hqdefault.jpg" ta-insert-video="https://www.youtube.com/embed/sbQQKI1Fwo4" contenteditable="false" allowfullscreen="true" frameborder="0"><br></p>',
27+
'<p></p><p style="color: rgb(68, 68, 68);text-align: left;background-color: rgb(255, 255, 255);"><u><b>ATTITUDES:</b></u></p>'
28+
],
2329
testString(false)
2430
);
2531
});

0 commit comments

Comments
 (0)