Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for es module #1781

Merged
merged 1 commit into from
Apr 5, 2020
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/src/html/beautifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ var get_custom_beautifier_name = function(tag_check, raw_token) {
// For those without a type attribute use default;
if (typeAttribute.search('text/css') > -1) {
result = 'css';
} else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1) {
} else if (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
result = 'javascript';
} else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
result = 'html';
Expand Down
12 changes: 10 additions & 2 deletions js/test/generated/beautify-html-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,18 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be
'\n' +
'<input type="submit"></input>');
bth(
'<script type="text/javascript">var foo = "bar";</script>',
'<script type="text/javascript">console.log(1 + 1);</script>',
// -- output --
'<script type="text/javascript">\n' +
' var foo = "bar";\n' +
' console.log(1 + 1);\n' +
'</script>');

// Issue #1706 - es script module
bth(
'<script type="module">console.log(1 + 1);</script>',
// -- output --
'<script type="module">\n' +
' console.log(1 + 1);\n' +
'</script>');
bth(
'<script type="application/javascript">var foo = "bar";</script>',
Expand Down
12 changes: 10 additions & 2 deletions test/data/html/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,18 @@ exports.test_data = {
'<input type="submit"></input>'
]
}, {
input: '<script type="text/javascript">var foo = "bar";</script>',
input: '<script type="text/javascript">console.log(1 + 1);</script>',
output: [
'<script type="text/javascript">',
' var foo = "bar";',
' console.log(1 + 1);',
'</script>'
]
}, {
comment: 'Issue #1706 - es script module',
input: '<script type="module">console.log(1 + 1);</script>',
output: [
'<script type="module">',
' console.log(1 + 1);',
'</script>'
]
}, {
Expand Down