Skip to content

Commit 2526dd6

Browse files
authored
Add regression tests for nested elements with a tag name followed by a newline or tab
Simple elements compile without issue when the tag name is followed by any white space. Nested elements fail to emit the tag name when they contain newline or tab white space.
1 parent 874bf22 commit 2526dd6

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

test/js/unit-testing-react.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,24 @@ describe('jsxLoader.js', function() {
648648
expect(js).to.equal('"use strict";\nReact.createElement(Test, {message: "test", value: 123}, "Hello")');
649649
});
650650

651+
it('should compile nested element with newline', function() {
652+
resetIfUsingPreact();
653+
var jsx = '<Test message="test" value={123}><div\ntitle="test">Hello</div></Test>';
654+
var js = jsxLoader.compiler.compile(jsx);
655+
console.log(js);
656+
console.log(JSON.stringify(js));
657+
expect(js).to.equal('"use strict";\nReact.createElement(Test, {message: "test", value: 123}, \n React.createElement("div", {title: "test"}, "Hello"))');
658+
});
659+
660+
it('should compile nested element with tab', function() {
661+
resetIfUsingPreact();
662+
var jsx = '<Test message="test" value={123}><div\ttitle="test">Hello</div></Test>';
663+
var js = jsxLoader.compiler.compile(jsx);
664+
console.log(js);
665+
console.log(JSON.stringify(js));
666+
expect(js).to.equal('"use strict";\nReact.createElement(Test, {message: "test", value: 123}, \n React.createElement("div", {title: "test"}, "Hello"))');
667+
});
668+
651669
it('should have correct child whitespace nodes', function() {
652670
resetIfUsingPreact();
653671
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>';
@@ -863,4 +881,4 @@ describe('<JsonData>', function() {
863881
expect(el.style.color).to.equal('rgb(255, 255, 255)');
864882
});
865883
});
866-
});
884+
});

0 commit comments

Comments
 (0)