npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-disable-document-write

v0.1.3

Published

Disables or reassigns document.write to prevent a blank page.

Downloads

195

Readme

Ember-disable-document-write

Travis CI Build Status

Why disable document.write?

Have you ever had users of your Ember app complain about your site going completely blank for no apparent reason? You and your customers are probably experiencing an unwanted side effect from third party code trying to insert a script into your page using document.write().

Calling document.write() on a page with an Ember app has the unfortunate side effect of completely replacing the content of your page with whatever is passed as an argument, effectively blanking out your page. This is because document.write() will call document.open() on an already loaded document (see notes section here), which clears the contents that were written previously.

Most developers avoid using document.write for this exact reason, however in this age of third party ads and addons, you never know when someone's irresponsible use of document.write is going to bite you.

What can we do about it?

One common way to prevent third parties from using document.write is to reassign the function to a non-operation. That's the approach this addon takes, using a service and an instance initializer to replace the document.write function with whatever you'd like (or a noop by default).

Write function replacement

This addon provides a document-service blueprint to generate a services/document.js to allow you to override the write function.

ember generate document-service

This will generate the following:

// app/services/document.js
import DocumentService from 'ember-disable-document-write/services/document';

export default DocumentService.extend({
    /*
    init() {
        this._super(...arguments);
    },
    */
    write(/* content */) {
        // insert any functionality to be executed when document.write is called
        // you can log, report, or use a "safe" write option like `Node.insertBefore` or `document.appendChild`
    }
});

Contributing

This README outlines the details of collaborating on this Ember addon.

Installation

  • git clone <repository-url> this repository
  • cd ember-disable-document-write
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:each && npm run nodetest to test your addon against multiple Ember versions)
  • ember test
  • ember test --server
  • npm run nodetest

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.