@@ -178,13 +178,15 @@ ${`<p>${'Lorem ipsum dolor sit amet. '.repeat(20)}</p>\n`.repeat(20)}
178178
179179 const file = await unified ()
180180 .use (rehypeParse, {fragment: true })
181- .use (() => (tree ) => {
182- tree .children .push ({
183- type: ' element' ,
184- tagName: ' script' ,
185- properties: {type: ' module' },
186- children: [{type: ' text' , value: browser}]
187- })
181+ .use (function () {
182+ return function (tree ) {
183+ tree .children .push ({
184+ type: ' element' ,
185+ tagName: ' script' ,
186+ properties: {type: ' module' },
187+ children: [{type: ' text' , value: browser}]
188+ })
189+ }
188190 })
189191 .use (rehypeStringify)
190192 .process (document )
@@ -221,9 +223,9 @@ Changing `example.js`:
221223 const file = await unified()
222224 .use(rehypeParse, {fragment: true})
223225+ .use(rehypeSanitize)
224- .use(() => (tree) => {
225- tree.children.push( {
226- type: 'element',
226+ .use(function () {
227+ return function (tree) {
228+ tree.children.push({
227229```
228230
229231Now yields:
@@ -255,14 +257,14 @@ window.addEventListener('hashchange', hashchange)
255257// doesn’t emit `hashchange`.
256258document .addEventListener (
257259 ' click' ,
258- (event ) => {
260+ function (event ) {
259261 if (
260262 event .target &&
261263 event .target instanceof HTMLAnchorElement &&
262264 event .target .href === location .href &&
263265 location .hash .length > 1
264266 ) {
265- setTimeout (() => {
267+ setImmediate ( function () {
266268 if (! event .defaultPrevented ) {
267269 hashchange ()
268270 }
@@ -273,7 +275,7 @@ document.addEventListener(
273275)
274276
275277function hashchange () {
276- /** @type {string| undefined} */
278+ /** @type {string | undefined} */
277279 let hash
278280
279281 try {
@@ -287,9 +289,9 @@ function hashchange() {
287289 document .getElementById (name) || document .getElementsByName (name)[0 ]
288290
289291 if (target) {
290- setTimeout (() => {
292+ setImmediate ( function () {
291293 target .scrollIntoView ()
292- }, 0 )
294+ })
293295 }
294296}
295297```
0 commit comments