pubsub.js
pubsub.js copied to clipboard
splice() requires 2 arguments in IE8
It is a known bug in older versions of IE that it requires 2nd argument for Array.splice()
, see e.g. this http://stackoverflow.com/a/8333160/1047880
This bug effectively prevents pubsub from retrieving published message (https://github.com/federico-lox/pubsub.js/blob/master/src/pubsub.js#L56) in IE7/8.
- with missing argument
Array.prototype.splice.call(args, 1)
always returns empty object, resulting in always publishing empty message.
This contradicts with compatibility list declared at https://github.com/federico-lox/pubsub.js#supported-platforms.
Thanks for the report.
I'll have a look :-)
Probably I was not straightforward: in IE7/8, splice()
requires 2 arguments, while you provide only 1.
Without the 2nd argument, splice()
will silently do nothing in IE7/8, effectively returning empty array, see the screenshot from IE8 developer console.
So Array.prototype.splice.call(args, 1)
should be changed to Array.prototype.splice.call(args, 1, args.length-1)
Thanks for the additional information.
The original report was pretty much clear, I just decided to consistently rework the code to get some improvements for all the targets (API, performace, testability) rather than just fix this specific issue for IE7/8.
In the version I'm (slowly) working on, this call and the usage of splat args will not be present anymore.
If you need this change in the short term let me know.