Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

phantomjs-shim

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phantomjs-shim

ES5, html5 api support form phantomjs sandbox

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by142.86%
Maintainers
1
Weekly downloads
 
Created
Source

Phantomjs-shim

Add shim for phantomjs

Usage

Require this module in phantomjs's and use browserify to recursively analyze all the require() calls in your app in order to build a bundle you can serve up to the browser in a single

// sandbox.js

require('@ali/phantomjs-shim')('#theme-style'); // '#theme-style' is specific `<style />` tag's selector in the HTML document

var bodyEl = document.querySelector('body');

return getComputedStyle(bodyEl);
// phantomJS-evaluate.js

const driver = require('node-phantom-promise');
const phantomjs = require('phantomjs-prebuilt');

...

    * evaluate(options) {
        const { url, type, viewWidth, language } = options;
        const status = yield this.page.open(url);
        
        // Bundle node-style javascript
        const code = yield new Promise((resolve, reject) => {
            browserify('./sandbox.js').bundle((err, buf) => {
                if (err) {
                    reject(err);
                    return;
                }
                resolve(buf.toString('utf-8'));
            })
        });

        // Evaluate bundled javascript
        bodyStyle = yield this.page.evaluate(new Function(
                'type',
                'htmlStr',
                'viewPort',
                'renderLanguage',
                code
            )
            , type, ''
            , viewWidth
            , language
        );

        return bodyStyle;
    }

...

Features

  • AutoPrefix CSS3
  • Disable CSS3 animation
  • Handle external CSS
  • Add es5 shim
  • Add classList shim

Keywords

FAQs

Package last updated on 24 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc