Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/react/jsxLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@
}
} else if (nextChar === '>') {
break;
} else if (nextChar === ' ') {
} else if (nextChar === ' ' || nextChar === '\n' || nextChar === '\t') {
foundName = true;
continue;
} else if (nextChar === ')' || nextChar === '&' || nextChar === '|' || nextChar === '?' || nextChar === ';') {
Expand Down
20 changes: 19 additions & 1 deletion test/js/unit-testing-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,24 @@ describe('jsxLoader.js', function() {
expect(js).to.equal('"use strict";\nReact.createElement(Test, {message: "test", value: 123}, "Hello")');
});

it('should compile nested element with newline', function() {
resetIfUsingPreact();
var jsx = '<Test message="test" value={123}><div\ntitle="test">Hello</div></Test>';
var js = jsxLoader.compiler.compile(jsx);
console.log(js);
console.log(JSON.stringify(js));
expect(js).to.equal('"use strict";\nReact.createElement(Test, {message: "test", value: 123}, \n React.createElement("div", {title: "test"}, "Hello"))');
});

it('should compile nested element with tab', function() {
resetIfUsingPreact();
var jsx = '<Test message="test" value={123}><div\ttitle="test">Hello</div></Test>';
var js = jsxLoader.compiler.compile(jsx);
console.log(js);
console.log(JSON.stringify(js));
expect(js).to.equal('"use strict";\nReact.createElement(Test, {message: "test", value: 123}, \n React.createElement("div", {title: "test"}, "Hello"))');
});

it('should have correct child whitespace nodes', function() {
resetIfUsingPreact();
var jsx = '<div><strong className={this.props.cssClass}>Test:</strong> {this.props.name} <section>Test [{this.props.name}] <span className="test">Test2</span></section></div>';
Expand Down Expand Up @@ -863,4 +881,4 @@ describe('<JsonData>', function() {
expect(el.style.color).to.equal('rgb(255, 255, 255)');
});
});
});
});