Commit 440cce9
committed
fix: answer DOM probes on NativeScriptDocument instead of throwing
* Angular discovers some optional configuration by reading the DOM. The
CSP_NONCE default factory, for example, evaluates
`DOCUMENT.body.querySelector('[ngCspNonce]')`. `NativeScriptDocument.body`
was a hollow object, so the optional chaining in those probes did not help
and they failed with `body?.querySelector is not a function`. Signal forms
reach this on the first `[formField]` binding, which crashed every
signal-form dialog at construction.
* `querySelector`, `querySelectorAll`, `getElementById`,
`getElementsByTagName` and `getElementsByClassName` now answer "nothing
found" on the document and on `body`/`head`. `createElement` still throws,
since constructing real nodes is a caller bug rather than a probe.
* CSP_NONCE is also provided as `null`, as there is no CSP in a NativeScript
runtime. It has to be a root provider: the root injector resolves
`providedIn: 'root'` tokens itself before consulting the platform injector,
so providing it in COMMON_PROVIDERS would have had no effect.1 parent 780e666 commit 440cce9
2 files changed
Lines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
40 | 57 | | |
41 | 58 | | |
42 | 59 | | |
43 | 60 | | |
| 61 | + | |
44 | 62 | | |
45 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
46 | 75 | | |
47 | 76 | | |
48 | 77 | | |
| |||
0 commit comments