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

ownerDocument.namespaces throws 'unspecified error' in IE8 #93

Open
juafrlo opened this issue Feb 26, 2013 · 2 comments
Open

ownerDocument.namespaces throws 'unspecified error' in IE8 #93

juafrlo opened this issue Feb 26, 2013 · 2 comments

Comments

@juafrlo
Copy link

juafrlo commented Feb 26, 2013

I'm using html5shiv in a project, and I have random errors here:

function shivPrint(ownerDocument) {
var shivedSheet,
wrappers,
data = getExpandoData(ownerDocument),
namespaces = ownerDocument.namespaces, ------> Here I got an error
ownerWindow = ownerDocument.parentWindow;
....

This function is called from:
shivPrint(document);

The javascript console throws this info about the error:
'unspecified error' in line...

It seems the ownerDocument (the document) is not set or initialized correctly at this point, and it happens only sometimes.
To avoid this error, I wait to window.onload event to call this function.

// Wait for onload to avoid load document error in IE8
window.onload = function() {
// shiv for print
shivPrint(document);
}

juafrlo added a commit to juafrlo/html5shiv that referenced this issue Feb 26, 2013
Wait for onload event to call shivPrint function.
This ensures the document is set and initialized, and avoids
random error when accessing document.namespaces
@aFarkas
Copy link
Owner

aFarkas commented Feb 27, 2013

@juafrlo

Thanks for your bugreport. I will look into this soon. The onload event might be to late. We could try to use a IE-only domcontentready method. Additionally window.onload = your function, can be overwritten or overwrites other event handler. It's not save.

@rtgibbons
Copy link

@juafrlo's fix worked for us - would be nice to get this fix formalized. (found this project and bug via modernizr)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants