Skip to content

Commit

Permalink
Update browser script to observe root resolved from script
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Aug 18, 2020
1 parent 8f825d3 commit 3e30fc6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions scripts/browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import browser from '../src/browser'
import { browser } from '../src/browser'

browser()
browser(document.currentScript.getRootNode())
5 changes: 1 addition & 4 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export const browser = (target: ParentNode = document): (() => void) => {
)
}

if (target[marpCoreBrowserScript]) {
console.warn("Marp Core's browser script has already executed.")
return target[marpCoreBrowserScript]
}
if (target[marpCoreBrowserScript]) return target[marpCoreBrowserScript]

const cleanupObserver = observer({ target })
const cleanup = () => {
Expand Down
5 changes: 3 additions & 2 deletions src/script/browser-script.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const dummy = 'This is a placeholder for the content of built browser script.'
const placeholder =
'This is a placeholder for the content of built browser script.'

export default dummy
export default placeholder

0 comments on commit 3e30fc6

Please sign in to comment.