Skip to content

Commit

Permalink
Fix several issues in Document.currentScript (#20852)
Browse files Browse the repository at this point in the history
- make `import.meta` as a code
- use `HTMLScriptElement` instead of `<script>`
  • Loading branch information
mfuji09 authored Sep 18, 2022
1 parent 6e550d3 commit f6a1d96
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions files/en-us/web/api/document/currentscript/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ browser-compat: api.Document.currentScript

{{APIRef("DOM")}}

The **`Document.currentScript`** property returns the {{HTMLElement("script")}} element whose script is currently being processed and [isn't a JavaScript module](https://github.com/whatwg/html/issues/997). (For modules use [import.meta](/en-US/docs/Web/JavaScript/Reference/Operators/import.meta) instead.)
The **`Document.currentScript`** property returns the {{HTMLElement("script")}} element whose script is currently being processed and [isn't a JavaScript module](https://github.com/whatwg/html/issues/997). (For modules use [`import.meta`](/en-US/docs/Web/JavaScript/Reference/Operators/import.meta) instead.)

It's important to note that this will not reference the {{HTMLElement("script")}}
element if the code in the script is being called as a callback or event handler; it
will only reference the element while it's initially being processed.

## Value

A {{HTMLElement("script")}} or null.
A {{domxref("HTMLScriptElement")}} or null.

## Examples

Expand All @@ -47,7 +47,7 @@ if (document.currentScript.async) {

## See also

- [import.meta](/en-US/docs/Web/JavaScript/Reference/Operators/import.meta)
- [`import.meta`](/en-US/docs/Web/JavaScript/Reference/Operators/import.meta)
- {{HTMLElement("script")}}
- {{DOMxRef("document.afterscriptexecute_event")}}
- {{DOMxRef("document.beforescriptexecute_event")}}

0 comments on commit f6a1d96

Please sign in to comment.