WebReflection / fix-babel-class

A runtime one-off fix for Babel transpiled classes
ISC License
6 stars 0 forks source link

fix-babel-class

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

Watch Out

A new transformer is out and running so you don't have to manually address what you need to fix.

This project is abandoned at this point, thank you.

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
);