Skip to content

Commit

Permalink
fix(define): remove element class bridge thanks to babel v7
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban committed Oct 4, 2018
1 parent fccb3f8 commit c0d6c9a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Web APIs polyfills for IE11
if ('ActiveXObject' in window) {
require('core-js/fn/array/find');
require('core-js/fn/reflect/construct');
require('core-js/es6/promise');
}

Expand Down
8 changes: 1 addition & 7 deletions src/define.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ if (process.env.NODE_ENV !== 'production') {
};
}

// BUG: Babel v6 transpiled class breaks native custom elements
export function HTMLBridge(...args) {
return Reflect.construct(HTMLElement, args, this.constructor);
}
Object.setPrototypeOf(HTMLBridge.prototype, HTMLElement.prototype);

const connects = new WeakMap();

function defineElement(tagName, hybridsOrConstructor) {
Expand Down Expand Up @@ -127,7 +121,7 @@ function defineElement(tagName, hybridsOrConstructor) {
throw Error(`[define] Element '${tagName}' already defined`);
}

class Hybrid extends HTMLBridge {
class Hybrid extends HTMLElement {
static get name() { return tagName; }

connectedCallback() {
Expand Down
4 changes: 2 additions & 2 deletions test/spec/define.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../helpers';
import define, { HTMLBridge } from '../../src/define';
import define from '../../src/define';
import { invalidate } from '../../src/cache';

describe('define:', () => {
Expand All @@ -23,7 +23,7 @@ describe('define:', () => {
});

it('defines custom elements constructor', () => {
class TestHtmlDefineExternalA extends HTMLBridge {
class TestHtmlDefineExternalA extends HTMLElement {
constructor() {
super();
this.value = 'test';
Expand Down
4 changes: 2 additions & 2 deletions test/spec/html.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { html } from '../../src/html';
import { createInternalWalker } from '../../src/html/template';
import define, { HTMLBridge } from '../../src/define';
import define from '../../src/define';

describe('html:', () => {
let fragment;
Expand Down Expand Up @@ -552,7 +552,7 @@ describe('html:', () => {
});

describe('use external element with shadowRoot', () => {
class TestExternalElement extends HTMLBridge {
class TestExternalElement extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: 'open' });
Expand Down

0 comments on commit c0d6c9a

Please # to comment.