From 2cb9497d02afdcfc19ea52fddcd6d1f04d81ffdb Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 12 Oct 2010 21:52:04 -0700 Subject: Fixed issue where compiler would pass in detached text node if previous markup would have removed it. --- regression/jqLite_after_NPE.html | 24 ++++++++++++++++++++++++ src/Compiler.js | 26 +++++++++++--------------- src/markups.js | 2 +- test/CompilerSpec.js | 23 +++++++++++++++++++++++ 4 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 regression/jqLite_after_NPE.html diff --git a/regression/jqLite_after_NPE.html b/regression/jqLite_after_NPE.html new file mode 100644 index 00000000..a914e953 --- /dev/null +++ b/regression/jqLite_after_NPE.html @@ -0,0 +1,24 @@ + + + + + + + +{{1+3}} +xxx +--- +xxx + + \ No newline at end of file diff --git a/src/Compiler.js b/src/Compiler.js index a78a04c9..9263dc02 100644 --- a/src/Compiler.js +++ b/src/Compiler.js @@ -158,12 +158,17 @@ Compiler.prototype = { } if (descend){ // process markup for text nodes only - eachTextNode(element, function(textNode){ - var text = textNode.text(); - foreach(self.markup, function(markup){ - markup.call(selfApi, text, textNode, element); - }); - }); + for(var i=0, child=element[0].childNodes; + i -1) { + textNode.after(text.substring(index + 3)); + textNode.after("
"); + textNode.after(text.substring(0, index)); + textNode.remove(); + } + }); + markup.push(function(text, textNode, parent){ + var index = text.indexOf('==='); + if (index > -1) { + textNode.after(text.substring(index + 3)); + textNode.after("

"); + textNode.after(text.substring(0, index)); + textNode.remove(); + } + }); + var scope = compile('A---B---C===D'); + expect(sortedHtml(scope.$element)).toEqual('

A
B
C

D
'); + }); + }); -- cgit v1.2.3