bind polyfill for PhantomJS

前端 未结 1 1821
清歌不尽
清歌不尽 2020-12-11 23:01

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 ex

相关标签:
1条回答
  • 2020-12-11 23:39

    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);
            }
        }
    
    0 讨论(0)
提交回复
热议问题