webkit-assign
Due to WebKit issue #138038, assigning to a property of 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 likely to
occur in recent versions of Angular.js and PDF.js.
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
.
Usage
webkit-assign
provides a CLI interface (when installed globally via npm i -g webkit-assign
). Specify any number of files, and each one will be transformed
and saved to a file with a .webkitassign.js
extension in the same directory.
For instance, the below command produces a transformed version of angular.js
with the name angular.webkitassign.js
in the same directory:
$ webkit-assign angular.js
In Node.js, you can require webkit-assign
(when installed locally via npm i webkit-assign
), and pass code to the module as a string:
var fs = ;var webkitAssign = ;var original = fs;var transformed = ;fs;
You can also obtain a transform stream by calling webkitAssign()
(without any
arguments), and pipe code through it:
var fs = ;var webkitAssign = ;fs ;
Plugins
We offer several plugins, all hosted in this repository.
A gulp plugin:
var gulp = ;var webkitAssign = ;gulp ;
A Browserify transform:
"browserify": "transform": "webkit-assign/browserify"
A Webpack loader:
loaders: test: /angular\.js$/ loader: 'webkit-assign/webpack'
Contributing
Install the module locally via git:
$ git clone https://github.com/StoryCloud/webkit-assign.git$ cd webkit-assign$ npm install$ npm link
Please provide unit tests and documentation for any changes. Try to maintain
existing formatting and naming conventions. You can check your code with npm test
.