[Pkg-javascript-commits] [node-acorn-jsx] 469/484: Change Literal to JSXText
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:21:12 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit 00dd70ed374b4d3031ba97326c6911d11b058bf1
Author: Reyad Attiyat <reyad.attiyat at gmail.com>
Date: Sun May 14 05:35:13 2017 -0500
Change Literal to JSXText
Fixes #73
---
inject.js | 11 ++++++++++-
test/tests-jsx.js | 20 ++++++++++----------
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/inject.js b/inject.js
index 2bc4e9f..d112032 100644
--- a/inject.js
+++ b/inject.js
@@ -351,6 +351,15 @@ module.exports = function(acorn) {
return this.finishNode(node, 'JSXElement');
};
+ // Parse JSX text
+
+ pp.jsx_parseText = function(value) {
+ var node = this.parseLiteral(value);
+ node.type = "JSXText";
+
+ return node;
+ };
+
// Parses entire JSX element from current position.
pp.jsx_parseElement = function() {
@@ -376,7 +385,7 @@ module.exports = function(acorn) {
instance.extend('parseExprAtom', function(inner) {
return function(refShortHandDefaultPos) {
if (this.type === tt.jsxText)
- return this.parseLiteral(this.value);
+ return this.jsx_parseText(this.value);
else if (this.type === tt.jsxTagStart)
return this.jsx_parseElement();
else
diff --git a/test/tests-jsx.js b/test/tests-jsx.js
index 5c7d8d8..6d8941c 100644
--- a/test/tests-jsx.js
+++ b/test/tests-jsx.js
@@ -214,7 +214,7 @@ var fbTestFixture = {
}
},
children: [{
- type: 'Literal',
+ type: 'JSXText',
value: ' ',
raw: ' ',
range: [15, 16],
@@ -239,7 +239,7 @@ var fbTestFixture = {
end: { line: 1, column: 23 }
}
}, {
- type: 'Literal',
+ type: 'JSXText',
value: ' ',
raw: ' ',
range: [23, 24],
@@ -735,7 +735,7 @@ var fbTestFixture = {
},
children: [
{
- type: "Literal",
+ type: "JSXText",
value: "\nbar\nbaz\n",
raw: "\nbar\nbaz\n",
range: [
@@ -1238,7 +1238,7 @@ var fbTestFixture = {
}
},
children: [{
- type: 'Literal',
+ type: 'JSXText',
value: '@test content',
raw: '@test content',
range: [5, 18],
@@ -1392,7 +1392,7 @@ var fbTestFixture = {
}
}
}, {
- type: 'Literal',
+ type: 'JSXText',
value: '7x invalid-js-identifier',
raw: '7x invalid-js-identifier',
range: [
@@ -1654,7 +1654,7 @@ var fbTestFixture = {
},
"children": [
{
- "type": "Literal",
+ "type": "JSXText",
"value": "monkeys /> gorillas",
"raw": "monkeys /> gorillas",
"range": [
@@ -3200,7 +3200,7 @@ var fbTestFixture = {
},
children: [
{
- type: "Literal",
+ type: "JSXText",
start: 3,
end: 7,
value: "foo ",
@@ -3252,7 +3252,7 @@ var fbTestFixture = {
}
},
children: [{
- type: "Literal",
+ type: "JSXText",
start: 22,
end: 26,
value: " bar",
@@ -3260,7 +3260,7 @@ var fbTestFixture = {
}]
},
{
- type: "Literal",
+ type: "JSXText",
start: 30,
end: 34,
value: " baz",
@@ -3441,7 +3441,7 @@ var fbTestFixture = {
}
},
children: [{
- type: "Literal",
+ type: "JSXText",
start: 5,
end: 10,
value: "/text",
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list