Skip to content

Latest commit

 

History

History
96 lines (73 loc) · 2 KB

README.md

File metadata and controls

96 lines (73 loc) · 2 KB

webkit-assign Build Status

Due to WebKit issue #138038, assigning to a property on an object created with Object.create may result in the error TypeError: Attempted to assign to readonly property.. This bug is known to affect iOS 8 users and is particularly likely to happen in recent versions of Angular.js (at least version 1.4.2).

This utility rewrites the following code

object.$$a = 5;

to this

var __webkitAssign__$$a = '$$a';
object[__webkitAssign__$$a] = 5;

as a workaround to prevent a TypeError.

Installation

Via npm:

$ npm install -g webkit-assign

Via git:

$ git clone https://github.com/StoryCloud/webkit-assign.git
$ cd webkit-assign
$ npm install
$ npm link

Usage

In a directory with the file angular.js, create a transformed angular.webkitassign.js in the same directory:

$ webkit-assign angular.js

In a Node.js program, you can obtain a transform stream by calling webkitAssign(), and pipe code through it.

var fs = require('fs');
var webkitAssign = require('webkit-assign');
fs.createReadStream('bower_components/angular/angular.js')
    .pipe(webkitAssign())
    .pipe(fs.createWriteStream('build/scripts/angular.js'));

We also offer a gulp plugin:

var gulp = require('gulp');
var webkitAssign = require('webkit-assign/gulp');
gulp.src('bower_components/angular/angular.js')
    .pipe(webkitAssign())
    .pipe(gulp.dest('build/scripts'));

And a Browserify transform:

"browserify": {
  "transform": [
    "webkit-assign/browserify"
  ]
}

And a Webpack loader:

loaders: [
  {
    test: /angular\.js$/,
    loader: 'webkit-assign/webpack'
  }
]