Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom elements support #3187

Closed
0Decoherence opened this issue May 16, 2015 · 2 comments
Closed

Custom elements support #3187

0Decoherence opened this issue May 16, 2015 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@0Decoherence
Copy link

This transplies and works as expected (in chrome and opera and firefox since custom elements are fully implemented) but, if you paste it on the playground it will display some errors

             class View extends HTMLElement{

                createdCallback() {
                    var template = document.querySelector('#t1');
                    var clone = template.content.cloneNode(true);
                    var root = this.createShadowRoot();
                    root.appendChild(clone);
                    console.log("View created");
                }

                attachedCallback(){
                    console.log("View attached");
                }

                detachedCallback(){
                    console.log("View detached");
                }

                attributeChangedCallback(attrName,oldVal,newVale){
                    console.log(`attribute ${attrName} changed from ${oldVal} to ${newVale}`);
                }
            }

            document.registerElement('x-view', View);

those are:
1-A class may only extend another class.
2-Property content does not exist on type Element, Element is of type HTMLTemplate
3-createShadowRoot() does not exist on type View
4-registerElement does not exist in document definition..

@kitsonk
Copy link
Contributor

kitsonk commented May 16, 2015

There are a few things, first, you are trying to use a feature that is still draft and not yet officially part of the DOM. Therefore they won't likely be included in TypeScript until they are finalised. You will have to add the changes to the native types yourself.

Also, this relates to #1168 and while there are some ways around this, it needs a good solution to make what you are trying to do easy.

@danquirk
Copy link
Member

@kitsonk pretty much covered what's happening here. Going to dupe this against #1168

@danquirk danquirk added the Duplicate An existing issue was already created label May 18, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants