Skip to content

Commit

Permalink
chore(puppeteer): remove wrapFactory function
Browse files Browse the repository at this point in the history
  • Loading branch information
Anillc committed Aug 8, 2021
1 parent 4ba7373 commit 98d422a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/plugin-puppeteer/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { renderToStaticMarkup } from 'react-dom/server'
import { segment } from 'koishi-core'
import { inspect } from 'util'

function wrapFactory<F extends (...args: any) => any>(func: F) {
return (...args: Parameters<F>) => {
const node = Object.create(func.apply(null, args))
node[inspect.custom] = function () {
return segment('fragment', { content: renderToStaticMarkup(this) })
}
return node
function customJsxFactory(...args: Parameters<typeof createElement>) {
const node = Object.create(createElement.apply(null, args))
node[inspect.custom] = function () {
return segment('fragment', { content: renderToStaticMarkup(this) })
}
return node
}

internal.setGlobal(config.loaderConfig.jsxFactory, wrapFactory(createElement))
internal.setGlobal(config.loaderConfig.jsxFactory, customJsxFactory)
internal.setGlobal(config.loaderConfig.jsxFragment, Fragment)

0 comments on commit 98d422a

Please sign in to comment.