npm.io
0.1.0 • Published 9 years ago

fix-babel-class

Licence
ISC
Version
0.1.0
Deps
0
Vulns
0
Weekly
0
Stars
6

fix-babel-class

A runtime one-off fix for Babel broken transpiled classes.

class List extends Array {}

class CustomElement extends HTMLElement {}
customElements.define('custom-element', CustomElement);

// fix whenever you need classes you want
fixBabelClass(List);
fixBabelClass(CustomElement);

console.log(
  // this is **false** without the fix
  new List instanceof List,
  // this **breaks** without the fix
  new CustomElement instanceof CustomElement,
  // this **won't ever work** without the fix
  (new CustomElement).nodeName
);

Keywords