Flash: Attach fake body only when actually needed #1557

merged 1 commit into from Nov 4, 2015


None yet

3 participants

niksy commented Mar 16, 2015

I was getting the infamous IE8 error HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917) when trying to use and attach fake body to html. Little testing and trying and I came to the solution that attached body only when it’s actually needed for checking, and that’s in two places, but with additional check to se if it’s available inside docElement.

Is this making any sense? :)


@niksy so sorry you were ignored :[[[

Would you be able to rebase this off of master?


Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: d258ae4
Build details: https://travis-ci.org/modernizr-savage/Modernizr/builds/88341676

(Please note that this is a fully automated comment.)

niksy commented Oct 30, 2015

@patrickkettner now I’m sorry for keeping this unchecked :)

I’ve rebased this with the master and pushed the changes.

Again, I suppose this adjustment is valid, method only attaches fake body if it doesn’t exist on page and it does that only in blocks where there is a call for removeFakeBody.

Also, I’m working on a project which uses Flash detection and from time to time I would get two body elements which probably come from lack of proper cleanup. It’s really rare, but when checking for existence of body elements via document.querySelectorAll('body'), I get two elements and problems start to happen then (some scripts look for body at specific time and they get fake body which doesn’t have any children). If there is only one body element, everything works OK.


hey @niksy!

The fix looks good, but could you fixup the style issues?


@niksy @niksy niksy Flash: Attach fake body only when actually needed
niksy commented Oct 31, 2015

@patrickkettner sure! I’ve made amends to the commit and now everything should be fine.

@patrickkettner patrickkettner merged commit 161a16e into Modernizr:master Nov 4, 2015

2 checks passed

continuous-integration/appveyor AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed

thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment