pubsub.js icon indicating copy to clipboard operation
pubsub.js copied to clipboard

splice() requires 2 arguments in IE8

Open dev101 opened this issue 12 years ago • 3 comments

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.

dev101 avatar Nov 29 '12 10:11 dev101

Thanks for the report.

I'll have a look :-)

federico-lox avatar Nov 30 '12 04:11 federico-lox

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)

dev101 avatar Feb 21 '13 10:02 dev101

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.

federico-lox avatar Mar 06 '13 19:03 federico-lox