npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

object-defineproperty-ie

1.2.0 • Public • Published

简体中文 | English

Object.defineProperty Sham For IE  Version

A Object.defineProperty sham based on VBScript for IE. It also provides Object.defineProperties, Object.getOwnPropertyDescriptor, Object.getOwnPropertyDescriptors.

Notice

  1. Use native method for Element object in IE8;
  2. In other case, Object.defineProperty will return a new VB object;
  3. VB object can't add or delete properties freely;
  4. VB object doesn't have [[Prototype]] or __proto__;
  5. The properties of VB object is enumerable even if descriptor enumerable is false;

Installation

  1. Use NPM: npm install -S object-defineproperty-ie
  2. Download directly: Development Version, Production Version

Usage

<script src="path/to/object-defineproperty-ie.js" type="text/javascript"></script>
<script type="text/javascript">
    var oldObj = Object.defineProperty({}, 'string', {
        value: 'Ambit Tsai',
        enumerable: true
    });
    // oldObj => {string: "Ambit Tsai"}
 
    var newObj = Object.defineProperties(oldObj, {
        getter: {
            get: function () {
                return this.string;
            }
        },
        setter: {
            set: function (value) {
                this.string = value;
            }
        }
    });
    // newObj => {
    //     getter: "Ambit Tsai",
    //     setter: undefined,
    //     string: "Ambit Tsai"
    // }
 
    var desc = Object.getOwnPropertyDescriptor(newObj, 'string');
    // desc => {
    //     configurable: false,
    //     enumerable: true,
    //     value: "Ambit Tsai",
    //     writable: false
    // }
</script> 

Testing

Accessing test/index.html with browser

Contact Us

  1. WeChat: ambit_tsai
  2. QQ Group: 663286147
  3. E-mail: ambit_tsai@qq.com

Reference

  1. 迷你MVVM框架avalon在兼容旧式IE做的努力

install

npm i object-defineproperty-ie

Downloadsweekly downloads

6

version

1.2.0

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability