question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Invalid calling object" error in IE

See original GitHub issue

Vue.js version

1.0.28

Reproduction Link

I’ve identified what is needed to fix the bug and I think, by inspection, it is the right thing to do. Producing a fiddle to reproduce this is somewhat complex and seems out of proportion to the fix, however if I absolutely have to then I will.

Steps to reproduce

Where there is an app with dynamic elements with transitions defined with callback hooks on the transitions, open it in IE (tested in 11 and 9,10 through emulation. No problem in other browsers)

What is Expected?

The transition completes with the hooks called at the right times.

What is actually happening?

The transition does not complete and an error is thrown in Vue: “Invalid calling object” on this code (which starts on line 37 src/transition.js, the error is thrown on line 40):

const raf = inBrowser && window.requestAnimationFrame
const waitForTransitionStart = raf
  /* istanbul ignore next */
  ? function (fn) { raf(function () { raf(fn) }) } //<-- error thrown here!
  : function (fn) { setTimeout(fn, 50) }

The error seems to be because the requestAnimationFrame method of the window object is being called without its parent object.

What seems to fix it?

By changing line 37 to

const raf = inBrowser && window.requestAnimationFrame.bind(window)

the error goes away. Using bind seems, to me, obviously correct. Clealy in other browsers because the default this is the window object anyway it should not matter, however IE seems to take a dislike to this approach and throw the error. Binding window to the method would seem harmless otherwise.

I’m an old-hand at coding but new to github (and relatively new to JS and vue) - The fix works but I don’t really know if there are other reasons why this is not a good idea so I’m cautious about just closing it.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rheuplercommented, May 15, 2018

Still running into this error in IE Edge.

1reaction
euan-smithcommented, Jan 16, 2017

OK, so I think I know what is hapenning, and unfortunately I don’t know how to reproduce it on jsfiddle.

basically my code is built with webpack and “use strict” is the case everywhere.

According to mdn when a method is called with an undefiend this (which is the case here) then when NOT in strict mode then this=window however when "use strict" is enabled then this stays undefined.

It would seem that the call to raf detached from the window object should, then, in strict mode throw the error I see and it would be best practice to fix it. It would also seem to be the case that in everything except ie that all is good. I’m testing the code using the standard vue builder and npm run dev which executes code in eval statements for hot-reloading. Note that on ie the following throws an error: eval('"use strict";var raf=window.requestAnimationFrame;raf(function(){})'); but not, for example, in Chrome or Firefox.

Is that enough evidence of an issue to get it fixed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Calling Object error in IE
This form seems to works though: ({}).toString();. Both forms appear to work fine in chrome, am I missing something?
Read more >
Internet Explorer 11 and Edge throws error Invalid calling ...
Hello, I am getting the following error in Internet Explorer 11 and Edge. It works perfectly fine under Safari, Chrome, Firefox: The file ......
Read more >
TypeError invalid calling object using IE 11 : r/angular
Hi everyone, I'm getting the error "invalid calling object" when i use IE on a function that makes an Http request, I'm using...
Read more >
Invalid calling object error when using Matter in IE11 - Phaser 3
I'm getting an “Invalid calling object” error in IE11 when using Matter physics. The code that generates the error is in the Matter....
Read more >
Error messages: __Message: Invalid calling object__Line
Error messages: __Message: Invalid calling object__Line: 50__Char: 1__Code: ... Is it an IE problem or is it specific to certain websites.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found