diff --git a/mustache.js b/mustache.js index 75f98ac..194815b 100644 --- a/mustache.js +++ b/mustache.js @@ -114,7 +114,7 @@ var Mustache; /** * Tries to match the given regular expression at the current position. - * Returns the matched text if it can match, `null` otherwise. + * Returns the matched text if it can match, the empty string otherwise. */ Scanner.prototype.scan = function (re) { var match = this.tail.match(re); @@ -125,13 +125,12 @@ var Mustache; return match[0]; } - return null; + return ""; }; /** * Skips all text until the given regular expression can be matched. Returns - * the skipped string, which is the entire tail of this scanner if no match - * can be made. + * the skipped string, which is the entire tail if no match can be made. */ Scanner.prototype.scanUntil = function (re) { var match, pos = this.tail.search(re); @@ -143,7 +142,7 @@ var Mustache; this.tail = ""; break; case 0: - match = null; + match = ""; break; default: match = this.tail.substring(0, pos); diff --git a/test/scanner_test.js b/test/scanner_test.js index 79def2f..7c03a2a 100644 --- a/test/scanner_test.js +++ b/test/scanner_test.js @@ -47,8 +47,8 @@ vows.describe("Mustache.Scanner").addBatch({ var match = scanner.scan(/b/); this.callback(scanner, match); }, - "it should return null": function (scanner, match) { - assert.equal(match, null); + "it should return the empty string": function (scanner, match) { + assert.equal(match, ""); }, "it should not advance the internal pointer": function (scanner, match) { assert.equal(scanner.pos, 0); @@ -61,8 +61,8 @@ vows.describe("Mustache.Scanner").addBatch({ var match = scanner.scan(/z/); this.callback(scanner, match); }, - "it should return null": function (scanner, match) { - assert.equal(match, null); + "it should return the empty string": function (scanner, match) { + assert.equal(match, ""); }, "it should not advance the internal pointer": function (scanner, match) { assert.equal(scanner.pos, 0); @@ -77,8 +77,8 @@ vows.describe("Mustache.Scanner").addBatch({ var match = scanner.scanUntil(/a/); this.callback(scanner, match); }, - "it should return null": function (scanner, match) { - assert.equal(match, null) + "it should return the empty string": function (scanner, match) { + assert.equal(match, "") }, "it should not advance the internal pointer": function (scanner, match) { assert.equal(scanner.pos, 0);