diff --git a/changelog_unreleased/angular/20014.md b/changelog_unreleased/angular/20014.md
new file mode 100644
index 000000000..3bfb0ef09
--- /dev/null
+++ b/changelog_unreleased/angular/20014.md
@@ -0,0 +1,22 @@
+#### Support `@boundary` error boundaries (#20014 by @Yahiro025)
+
+
+```html
+
+@boundary {
+
{{err.message}}
+} + + +SyntaxError: Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) (6:1) + + +@boundary { +{{ err.message }}
+} +``` diff --git a/package.json b/package.json index c70df16d6..36465b733 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "acorn": "8.18.0", "acorn-jsx": "5.3.2", "angular-estree-parser": "15.5.0", - "angular-html-parser": "10.11.0", + "angular-html-parser": "10.12.0", "camelcase": "9.0.0", "ci-info": "4.4.0", "cjk-regex": "3.4.2", diff --git a/scripts/build/transform/index.js b/scripts/build/transform/index.js index 34a2ce332..6079d6b63 100644 --- a/scripts/build/transform/index.js +++ b/scripts/build/transform/index.js @@ -28,7 +28,10 @@ const packageTransforms = new Map([ transforms["method-at"], ["@glimmer/syntax", "angular-estree-parser", "espree"], ], - [transforms["object-has-own"], ["@babel/parser", "graphql"]], + [ + transforms["object-has-own"], + ["@babel/parser", "graphql", "angular-html-parser"], + ], [transforms["string-raw"], ["camelcase", "@angular/compiler", "js-yaml"]], [transforms["method-is-well-formed"], ["meriyah"]], /* spell-checker: enable */ diff --git a/src/language-html/print/angular-control-flow-block-settings.evaluate.js b/src/language-html/print/angular-control-flow-block-settings.evaluate.js index bc9b33c23..48243b99a 100644 --- a/src/language-html/print/angular-control-flow-block-settings.evaluate.js +++ b/src/language-html/print/angular-control-flow-block-settings.evaluate.js @@ -15,6 +15,8 @@ const ANGULAR_CONTROL_FLOW_BLOCK_SETTINGS = new Map( ["placeholder", ["placeholder", "error", "loading"]], ["error", ["placeholder", "error", "loading"]], ["loading", ["placeholder", "error", "loading"]], + + ["boundary", ["error"]], ] .filter(([, followingBlockNames]) => followingBlockNames.length > 0) .map(([name, followingBlockNames]) => [name, new Set(followingBlockNames)]), diff --git a/tests/format/angular/control-flow/__snapshots__/format.test.js.snap b/tests/format/angular/control-flow/__snapshots__/format.test.js.snap index 8cf72183e..f5f199f6e 100644 --- a/tests/format/angular/control-flow/__snapshots__/format.test.js.snap +++ b/tests/format/angular/control-flow/__snapshots__/format.test.js.snap @@ -52,6 +52,258 @@ parsers: ["angular"] ================================================================================ `; +exports[`boundary.html format 1`] = ` +====================================options===================================== +parsers: ["angular"] + printWidth: 80 (default) | +=====================================input====================================== +@boundary { +Something went wrong!
+} + +@boundary { +Error occurred: {{ $error.message }}
+} + +@boundary { +Loading failed.
+ +} + +@boundary { +Network issue. Check your connection.
+ +} @error { +An unexpected error occurred: {{ $error.message }}
+} + +@boundary { +Failed to load chart: {{err.message}}
+ +} + +@boundary { + Outer Main + @boundary { + Inner Main + } @error { + Inner Fallback + } +} @error { + Outer Fallback +} + +@defer { + @boundary { +Something went wrong!
+} + +@boundary { +Error occurred: {{ $error.message }}
+} + +@boundary { +Loading failed.
+ +} + +@boundary { +Network issue. Check your connection.
+ +} @error { +An unexpected error occurred: {{ $error.message }}
+} + +@boundary { +Failed to load chart: {{ err.message }}
+ +} + +@boundary { + Outer Main + @boundary { + Inner Main + } @error { + Inner Fallback + } +} @error { + Outer Fallback +} + +@defer { + @boundary { +Network issue. Check your connection.
+ +} @error { +An unexpected error occurred: {{$error.message}}
+} + +@boundary { +Failed to load chart: {{err.message}}
+ +} + +@boundary { + Main +} @error (let err; when err.message === '404') { + Not Found +} + +@boundary { + Main +} @error (err = $error, retry += +$reset) { + +} + +=====================================output===================================== +@boundary { +Network issue. Check your connection.
+ +} @error { +An unexpected error occurred: {{ $error.message }}
+} + +@boundary { +Failed to load chart: {{ err.message }}
+ +} + +@boundary { + Main +} @error (let err; when err.message === '404') { + Not Found +} + +@boundary { + Main +} @error (err = $error, retry += +$reset) { + +} + +================================================================================ +`; + exports[`chid.html format 1`] = ` ====================================options===================================== parsers: ["angular"] diff --git a/tests/format/angular/control-flow/boundary-error-parameters.html b/tests/format/angular/control-flow/boundary-error-parameters.html new file mode 100644 index 000000000..5bcec9af4 --- /dev/null +++ b/tests/format/angular/control-flow/boundary-error-parameters.html @@ -0,0 +1,45 @@ +@boundary { +Network issue. Check your connection.
+ +} @error { +An unexpected error occurred: {{$error.message}}
+} + +@boundary { +Failed to load chart: {{err.message}}
+ +} + +@boundary { + Main +} @error (let err; when err.message === '404') { + Not Found +} + +@boundary { + Main +} @error (err = $error, retry += +$reset) { + +} diff --git a/tests/format/angular/control-flow/boundary.html b/tests/format/angular/control-flow/boundary.html new file mode 100644 index 000000000..16d0ea579 --- /dev/null +++ b/tests/format/angular/control-flow/boundary.html @@ -0,0 +1,70 @@ +@boundary { +Something went wrong!
+} + +@boundary { +Error occurred: {{ $error.message }}
+} + +@boundary { +Loading failed.
+ +} + +@boundary { +Network issue. Check your connection.
+ +} @error { +An unexpected error occurred: {{ $error.message }}
+} + +@boundary { +Failed to load chart: {{err.message}}
+ +} + +@boundary { + Outer Main + @boundary { + Inner Main + } @error { + Inner Fallback + } +} @error { + Outer Fallback +} + +@defer { + @boundary { +