Skip to content

Commit

Permalink
revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Apr 4, 2019
1 parent dd9d521 commit 154e804
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/moon/dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
* @returns {String} Token converted into a string
*/

function stringToken(token) {
function tokenString(token) {
if (token.type === "tagOpen") {
if (token.value === "Text") {
var content = token.attributes[""]; // If the text content is surrounded with quotes, it was normal text
Expand Down Expand Up @@ -414,7 +414,7 @@
// surrounding tokens.

for (var i = Math.max(0, parseError.start - 1); i < Math.min(parseError.end + 1, tokens.length); i++) {
parseErrors += stringToken(tokens[i]);
parseErrors += tokenString(tokens[i]);
}

parseErrors += "\n\n";
Expand Down
2 changes: 1 addition & 1 deletion packages/moon/src/compiler/lexer/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const attributeRE = /\s*([\w\d-_]*)(?:=(?:("[\w\d-_]*"|'[\w\d-_]*')|{([\w\d-_]*)
* @param {Object} token
* @returns {String} Token converted into a string
*/
export function stringToken(token) {
export function tokenString(token) {
if (token.type === "tagOpen") {
if (token.value === "Text") {
const content = token.attributes[""];
Expand Down
4 changes: 2 additions & 2 deletions packages/moon/src/compiler/parser/parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stringToken } from "../lexer/lexer";
import { tokenString } from "../lexer/lexer";
import { error } from "../../util/util";

/**
Expand Down Expand Up @@ -211,7 +211,7 @@ export function parse(tokens) {
i < Math.min(parseError.end + 1, tokens.length);
i++
) {
parseErrors += stringToken(tokens[i]);
parseErrors += tokenString(tokens[i]);
}

parseErrors += "\n\n";
Expand Down
16 changes: 8 additions & 8 deletions packages/moon/test/compiler/lexer.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lex, stringToken } from "../../src/compiler/lexer/lexer";
import { lex, tokenString } from "../../src/compiler/lexer/lexer";

test("lex opening tag", () => {
expect(lex(`<div>`)).toEqual([{"attributes": {}, "closed": false, "type": "tagOpen", "value": "div"}]);
Expand Down Expand Up @@ -53,35 +53,35 @@ test("lex comments", () => {

test("opening tag token to string", () => {
const input = "<div>";
expect(stringToken(lex(input)[0])).toBe(input);
expect(tokenString(lex(input)[0])).toBe(input);
});

test("opening tag token with attributes to string", () => {
const input = `<div id="test-id" class='test-class' expression={dynamic}>`;
expect(stringToken(lex(input)[0])).toBe(input);
expect(tokenString(lex(input)[0])).toBe(input);
});

test("self-closing tag token to string", () => {
const input = `<input/>`;
expect(stringToken(lex(input)[0])).toBe(input);
expect(tokenString(lex(input)[0])).toBe(input);
});

test("self-closing tag token with attributes to string", () => {
const input = `<input id="test-id" class='test-class' expression={dynamic}/>`;
expect(stringToken(lex(input)[0])).toBe(input);
expect(tokenString(lex(input)[0])).toBe(input);
});

test("closing tag token to string", () => {
const input = `</div>`;
expect(stringToken(lex(input)[0])).toBe(input);
expect(tokenString(lex(input)[0])).toBe(input);
});

test("text token to string", () => {
const input = `Test Text`;
expect(stringToken(lex(input)[0])).toBe(input);
expect(tokenString(lex(input)[0])).toBe(input);
});

test("expression token to string", () => {
const input = `{dynamic + 1}`;
expect(stringToken(lex(input)[0])).toBe(input);
expect(tokenString(lex(input)[0])).toBe(input);
});

0 comments on commit 154e804

Please sign in to comment.