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

[1.0] Changes in appendChild from 0.9 to 1.0? #1657

Closed
madoublet opened this issue May 29, 2015 · 3 comments
Closed

[1.0] Changes in appendChild from 0.9 to 1.0? #1657

madoublet opened this issue May 29, 2015 · 3 comments

Comments

@madoublet
Copy link

After moving from 0.9 to 1.0, I noticed that all my components that rely on appending content to the light DOM have stopped working. I did not see any breaking changes related to this. Was I doing something wrong from the start or is this a bug?

Below is an example of what I am talking about. The below code does not work for me.

<dom-module id="respond-content">
  <template></template>
</dom-module>

<script>
  Polymer({
        is: "respond-content",

        // element attributes
        properties: {
            url: { type: String },
            contentid: { type: String },
            cssclass: { type: String }
        },

        // attached
        attached: function() {

            var toLight = document.createElement('div');
            toLight.innerHTML = '<h1>This worked in Polymer 0.9</h1>';
            Polymer.dom(this).appendChild(toLight);

        }

    });
</script>
@arthurevans
Copy link

Here you're creating a local DOM tree with nothing in it (by including the empty <template>). If you include a local DOM tree, it gets rendered in place of the children.

To render light DOM children (or "project" them into the local DOM), add an insertion point in local DOM by adding a <content> tag:

<template>
  <content></content>
</template>

I believe you were seeing the children render before because of a bug in 0.9.

@kevinpschaaf
Copy link
Member

Correct, this was a bug in 0.9 that was fixed. As @arthurevans mentioned you were missing a <content> insertion point in your template. Closing.

@madoublet
Copy link
Author

Perfect. Thank you, this fixed my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants