diff --git a/packages/next/src/client/app-bootstrap.ts b/packages/next/src/client/app-bootstrap.ts index f422b50c5e695..1811f9fa115ca 100644 --- a/packages/next/src/client/app-bootstrap.ts +++ b/packages/next/src/client/app-bootstrap.ts @@ -5,6 +5,8 @@ * - next/script with `beforeInteractive` strategy */ +import { setAttributesFromProps } from './set-attributes-from-props' + const version = process.env.__NEXT_VERSION window.next = { @@ -27,11 +29,7 @@ function loadScriptsInSequence( const el = document.createElement('script') if (props) { - for (const key in props) { - if (key !== 'children') { - el.setAttribute(key, props[key]) - } - } + setAttributesFromProps(el, props) } if (src) { diff --git a/test/e2e/app-dir/script-before-interactive/app/layout.tsx b/test/e2e/app-dir/script-before-interactive/app/layout.tsx new file mode 100644 index 0000000000000..dbce4ea8e3aeb --- /dev/null +++ b/test/e2e/app-dir/script-before-interactive/app/layout.tsx @@ -0,0 +1,11 @@ +export default function RootLayout({ + children, +}: { + children: React.ReactNode +}) { + return ( + + {children} + + ) +} diff --git a/test/e2e/app-dir/script-before-interactive/app/multiple/page.tsx b/test/e2e/app-dir/script-before-interactive/app/multiple/page.tsx new file mode 100644 index 0000000000000..b7d081ca9c9ea --- /dev/null +++ b/test/e2e/app-dir/script-before-interactive/app/multiple/page.tsx @@ -0,0 +1,34 @@ +import Script from 'next/script' + +export default function MultiplePage() { + return ( +
+

Multiple beforeInteractive Scripts Test

+