2017-02-27 9 views
1

webpack을 사용하여 간단한 사용자 정의 요소를 수행하는 동안이 오류가 발생합니다.TypeError : fakeClass가 생성자가 아닙니다.

내 설정 :

<script src="/custom-elements.min.js"></script> 
<script src="/native-shim.js"></script> 
export default class TodoApp extends HTMLElement { 
    constructor() { 
     super(); 
     console.log('CONSTRUCT'); 
    } 
} 

오류가 네이티브 심의 라인 (98)에 발생합니다

window.HTMLElement = function() { 
    if (!browserConstruction) { 
     const tagname = tagnameByConstructor.get(this.constructor); 
     const fakeClass = nativeGet.call(window.customElements, tagname); 

     // Make sure that the fake constructor doesn't call back to this constructor 
     userConstruction = true; 
     const instance = new (fakeClass)(); 
     return instance; 
    } 
    // Else do nothing. This will be reached by ES5-style classes doing 
    // HTMLElement.call() during initialization 
    browserConstruction = false; 
}; 

"태그 이름은"정의되지 않습니다.

"최신"을 포함하여 다른 버전의 베벨을 사용해 보았습니다. shim의 순서를 변경하고 기본 shim을 제외하고 시도했습니다.

답변

1

오류 메시지에 따르면 태그 이름이 없기 때문입니다.

당신은 예를 들어, 하나를 정의해야합니다 :

customElements.define('todo-app', TodoApp)