Metrics
0
Watch 1 Star 3 Fork 0

范围兄 / object-defineproperty-ieJavaScriptApache-2.0

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
一个 Object.defineProperty 的 IE 补丁,基于 VBScript 实现 spread retract

Clone or download
Loading...
README.md

简体中文 | 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做的努力

Comments ( 0 )

You need to Sign in for post a comment

Help Search