es5-polyfill

ECMAScript 5 Polyfill

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
es5-polyfill
3120.0.65 years ago5 years agoMinified + gzip package size for es5-polyfill in KB

Readme

ECMAScript 5 Polyfills

Object

Object.keys
Object.getPrototypeOf
Object.getOwnPropertyNames
Object.defineProperty 注意不要给普通对象添加属性时用 get/set,慎用
Object.defineProperties 慎用
Object.create

Array

Array.isArray
Array.prototype.forEach
Array.prototype.every
Array.prototype.fill
Array.prototype.filter
Array.prototype.find
Array.prototype.findIndex
Array.prototype.indexOf
Array.prototype.lastIndexOf
Array.prototype.map
Array.prototype.reduce
Array.prototype.reduceRight
Array.prototype.some

Function

Function.prototype.bind

String

String.prototype.trim

Date

Date.prototype.now
Date.prototype.toISOString

DOM相关

Document.getElementsByClassName
CustomEvent
Element.matches
Element.textContent

Element.getBoundingClientRect

弥补了IE中getBoundingClientRect取不到width/height的缺憾

事件绑定/解绑

IE中也使用addEventListener/removeEventListener方法进行事件绑定/解绑

window

getComputedStyle

为IE增加了此API的Polyfill

Viewport

获取当前窗口的一些属性已经做了兼容,可以直接使用如下属性来获取
window.innerWidth
window.innerHeight
window.pageXOffset
window.pageYOffset
window.scrollX
window.scrollY