phantomas icon indicating copy to clipboard operation
phantomas copied to clipboard

Baobab-related jsErrors

Open vs0562 opened this issue 11 years ago • 1 comments

I use Baobab (https://github.com/Yomguithereal/baobab) to store data models. When the app is loaded manually there is no js exceptions thrown. However the phantomas throws the following exception:

  • TypeError: 'undefined' is not a function (evaluating 'cloner.bind(null, false)') - unknown fn: @ 103 / unknown fn: @ 414

In the Baobab code the cloner function is defined right above the line in question:

// Cloning function function cloner(deep, item) { if (!item || typeof item !== 'object' || item instanceof Error || ('ArrayBuffer' in global && item instanceof ArrayBuffer)) return item;

// Array if (type.Array(item)) { if (deep) { var i, l, a = []; for (i = 0, l = item.length; i < l; i++) a.push(deepClone(item[i])); return a; } else { return item.slice(0); } }

// Date if (type.Date(item)) return new Date(item.getTime());

// RegExp if (item instanceof RegExp) return cloneRegexp(item);

// Object if (type.Object(item)) { var k, o = {};

if (item.constructor && item.constructor !== Object)
  o = Object.create(item.constructor.prototype);

for (k in item)
  if (item.hasOwnProperty(k))
    o[k] = deep ? deepClone(item[k]) : item[k];
return o;

}

return item; }

// Shallow & deep cloning functions var shallowClone = cloner.bind(null, false), deepClone = cloner.bind(null, true);

Is there any options I can set to eliminate the js exception in phantomas? Or is there any particular rule that is being violated?

vs0562 avatar Sep 04 '15 16:09 vs0562

See https://github.com/ariya/phantomjs/issues/10522 - PhantomJS 1.x does not provide Function.prototype.bind.

But there are good news :) Today I've released the new version of phantomas that provides the ability to run brand new and shiny PhantomJS 2.x.

macbre avatar Sep 12 '15 18:09 macbre