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

Fix IE "Invalid calling object" error (attach to DOM and then compile) #261

Merged
merged 3 commits into from
Nov 2, 2015

Conversation

jvmccarthy
Copy link
Contributor

Hi. I'm using ocLazyLoad in combination with angular-material and have run into an issue where using md-tabs in a lazy loaded module is causing "Invalid calling object" errors in IE11. Inside of the tabs controller, elements are being saved for variables using the getElementsByTagName() function. IE is invalidating the saved HTMLCollection objects once the compiled element is added to the parent DOM (this error does not occur in Firefox or Chrome). As a fix, the content should first be added to the parent DOM and then compiled (in ocLazyLoad.directive.js).

I've added a test to highlight this error which can be run without the fix on my ie_invalid_test branch. It can be observed by running gulp karma (with singleRun: false) and then opening IE11 to the karma port. In my tests, IE11 is also failing another test around a missing file, so you may have to focus on the specific test (change it to fit) in order to isolate this issue.

I'm also not sure why the build messed with the whitespace on the polyfill. If you like, I can see about cleaning that up. Also, I can file an issue for tracking and discussion, if you like.

Thank you for your time and consideration as well as your excellent work on this very important library!

John V McCarthy and others added 3 commits October 26, 2015 15:23
…on by adding the uncompiled content to the DOM and then compiling it. For example, if a controller in a lazy loaded module calls $element[0].getElementsByTagName('whatever'), IE will invalidated the returned HTMLCollection once the lazy loaded content is added to the DOM (this is not an issue in Firefox or Chrome). By adding the content and then compiling, we prevent IE from invalidating saved elements. (This issue was encountered when lazy loading a module that uses angular-material's md-tabs, which saves tab elements.)
@ocombe
Copy link
Owner

ocombe commented Oct 27, 2015

\o/ a PR with a test!!
Thanks a lot, I'll take a look at it :)

@ocombe
Copy link
Owner

ocombe commented Nov 2, 2015

Ahah looks like I just got the bug in one of my projects when I tester in IE.
Merging this, thanks :)

ocombe added a commit that referenced this pull request Nov 2, 2015
Fix IE "Invalid calling object" error (attach to DOM and then compile)
@ocombe ocombe merged commit 1b32308 into ocombe:master Nov 2, 2015
@ocombe
Copy link
Owner

ocombe commented Nov 2, 2015

Hmm I still have the same error on IE :-/

ocombe added a commit that referenced this pull request Nov 2, 2015
@jvmccarthy
Copy link
Contributor Author

Sorry to hear that. I'll take a look at master and see if I can reproduce the issue. I was testing with IE11. What version of IE were you testing with?

@ocombe
Copy link
Owner

ocombe commented Nov 2, 2015

It's ok, I fixed it in a new commit :)
I tested with IE11 as well... not sure why it was working with you and not with me, maybe a race condition.

@jvmccarthy
Copy link
Contributor Author

Thanks for tweaking my fix. Your changes look good. I appreciate you working with me on this one and getting it closed quickly!

@jvmccarthy jvmccarthy deleted the fix_ie_invalid branch November 2, 2015 17:34
@jvmccarthy jvmccarthy restored the fix_ie_invalid branch November 2, 2015 17:46
@jvmccarthy
Copy link
Contributor Author

@ocombe Sorry to bug you, but can you also publish 1.0.8 to npm? I'm only seeing 1.0.7 currently. Thanks!

@ocombe
Copy link
Owner

ocombe commented Nov 2, 2015

Yes sorry, done ! Thanks for the reminder :)

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

Successfully merging this pull request may close these issues.

2 participants