Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Issue where child code is run before document.body has a value #1277

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/child/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ const capitalizeFirstLetter = (string) =>

const isDef = (value) => `${value}` !== '' && value !== undefined

const usedTags = new WeakSet()
const addUsedTag = (el) => typeof el === 'object' && usedTags.add(el)

function getElementName(el) {
switch (true) {
case !isDef(el):
Expand Down Expand Up @@ -171,6 +174,8 @@ function init() {
setupMouseEvents()
startEventListeners()
inPageLinks = setupInPageLinks()
addUsedTag(document.documentElement)
addUsedTag(document.body)
sendSize('init', 'Init message from host page', undefined, undefined, VERSION)
sendTitle()
onReady()
Expand Down Expand Up @@ -849,13 +854,9 @@ function setupMutationObserver() {
bodyObserver = setupBodyMutationObserver()
}

const usedTags = new WeakSet()
usedTags.add(document.documentElement)
usedTags.add(document.body)

function usedEl(el) {
if (usedTags.has(el)) return true
usedTags.add(el)
addUsedTag(el)
info(
`\nHeight calculated from: ${getElementName(el)} (${elementSnippet(el)})`,
)
Expand Down
Loading