rhaboo icon indicating copy to clipboard operation
rhaboo copied to clipboard

"fill" corrupts namespace of PNotify and likely javascript libraries

Open alexpmorris opened this issue 9 years ago • 4 comments

I wanted to try rhaboo and had a strange conflict with PNotify. It turns out that PNotify was being redirected to use rhaboo's version of "fill". I basically solved the problem by commenting out fill:

var Array_rhaboo_originals = Array_rhaboo_originals || {
  pop : Array.prototype.pop,
  push : Array.prototype.push,
  shift : Array.prototype.shift,
  unshift : Array.prototype.unshift,
  splice : Array.prototype.splice,
  reverse : Array.prototype.reverse,
  sort : Array.prototype.sort,
  //fill : Array.prototype.fill,
};

//Array.prototype.fill = Array_rhaboo_defensively("fill");

I believe the problem also affects all the others as well (especially pop/push), so all of these probably need to be better encapsulated to avoid contaminating the variable namespace.

alexpmorris avatar Aug 31 '15 21:08 alexpmorris

Can I have a HTML demo for this one as well please?

adrianmay avatar Sep 02 '15 18:09 adrianmay

The other day I gave up and ended up trying jStorage instead, which worked for me right away without conflict. However, when I switched back to try and reproduce the problem again in the current version of my page, Rhaboo seemed to work perfectly this time around. It's possible there was an extra unclosed <div> somewhere in a PNotify or other area that somehow caused these conflicts with Rhaboo. I will let you know if I am able to get it to happen again.

alexpmorris avatar Sep 03 '15 18:09 alexpmorris

Hi,

I know this is a rather old issue, but I have the same problem as @alexpmorris had. As he suspected, it is an issue with push in my case. I use JQuery DataTables with a plugin called ColReorder. (see: https://datatables.net/extensions/colreorder) This plugin adds itself as a feature to the dataTable with this line: $.fn.dataTableExt.aoFeatures.push({...});

aoFeatures is an array, on which the push is called, but it gets redefined by rhaboo lib in arr.js like this: //This can be better cos it leaves the existing part of the array unchanged Array.prototype.push = function () { var l1 = this.length; var ret = Array_rhaboo_originals.push.apply(this, arguments); var l2 = this.length; //Just persist the new elements... if ( this._rhaboo !== undefined && l2>l1 ) { for (var i=l1; i<l2; i++) { R.storeProp(this, i); //This might be writing each slot twice } R.updateSlot(this); //for length } return ret; }

This results in an exception, and breaks my grid columns reordering. I have had no time trying to isolate this issue in a plunker project, will try to do it later. I use jspm to load my dependencies, so I am not sure if it is only my setup to be blamed...

Do you see anything suspicious based on this?

sirudog avatar Mar 14 '16 18:03 sirudog

OK, this issue has nothing to do with rhaboo.

I have downloaded ColReorder from github instead of npm via jspm, and that one works fine. I have also double-checked that the code in arr.js I copied here does not affect in any way the push method of the Array. I guess this issue can be closed then... if we all agree

sirudog avatar Mar 14 '16 18:03 sirudog