Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
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
Next Next commit
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.
  • Loading branch information
aaronhuggins authored Jul 28, 2025
commit 2526dd6a06fc9502bd965bafa33c93faee3c7b3d
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)');
});
});
});
});