bind polyfill for PhantomJS

江枫思渺然 提交于 2019-11-27 08:06:48

问题


I am trying to add bind polyfill in my phantomjs file using es5-shim.js.

I have tried to include es5-shim.js using require(), but I am still getting error when I execute the phantomjs file. What is the correct way to use this?


回答1:


I tried the polyfill in this link and it seems to work fine for me.

Note that phantomjs scripts run inside WebKit's JavaScriptCore engine (which uses ES5) so most of these functions should already come out of the box.

D:\>phantomjs.exe

phantomjs> console.log(Object.keys)
function keys() {
    [native code]
}
undefined

phantomjs> var shim = require("D:\\es5-shim.js");
undefined

phantomjs> console.log(Object.keys)
function keys(object) {
        if (isArguments(object)) {
            return originalKeys(ArrayPrototype.slice.call(object));
        } else {
            return originalKeys(object);
        }
    }


来源:https://stackoverflow.com/questions/24224323/bind-polyfill-for-phantomjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!