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

Trying to import core-ajax I get an appendChild on #document error #810

Closed
funkjunky opened this issue Oct 21, 2014 · 4 comments
Closed

Comments

@funkjunky
Copy link

Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Nodes of type 'HTML' may not be inserted inside nodes of type '#document'. polymer.concat.js:6313

The error is actually readable, but doesn't make sense to me in the context... is Polymer trying to attach the core-ajax template to the html node?

I'm including the core-ajax after including platform.js and my own created elements work fine.
I'm including core-ajax as thus:

<link href="/framework/lib/core-ajax/core-ajax.html" rel="import">

EDIT: Ok that took forever to find and google barely helped.

First of all, it's dumb that your system is so fragile that it breaks if included twice. Second, it's also ridiculous that shadow-dom doesn't keep it's scope for JS to itsself. Essentially including polymer.js in my code cause platform code to be included, which was apparently already included through core-ajax, which caused the appendChild error.

So if I want to use polymer without core-elements, then i need to include polymer.js. As soon as i add core-elements I have to remove that polymer.js include.

@ebidel
Copy link
Contributor

ebidel commented Oct 21, 2014

The idea is that you never include polymer.js directly...anwywhere. You always use an HTML import to bring in polymer.html:

<link rel="import" href="path/to/polymer.html">

The reason being that all elements that reference path/to/polymer.html will be re-duplicated by the browser (because they all point to the same URL).

It's also ridiculous that shadow-dom doesn't keep it's scope for JS to itself

Shadow DOM is a feature for DOM and css scoping. It doesn't have anything to say about JS.

@funkjunky
Copy link
Author

I admit ridiculous is a strong word; I still don't agree JS shouldn't be scoped in shadow DOM, but I see how it's debatable.

As for including polymer.js, are you suggesting one should always include polymer.html instead of polymer.js? because the documentation and samples for creating your own elements suggest including polymer.js. Perhaps those docs should be updated?

@arthurevans
Copy link

Where are you seeing polymer.js on the site? I thought the tutorial, creating elements pages, etc., all used the HTML import for polymer.html.

We do include platform.js -- that needs to be included using a <script> tag because it includes the polyfill for HTMLImports itself.

If we're suggesting polymer.js anywhere, that is almost undoubtedly a bug.

@funkjunky
Copy link
Author

hmmm I don't know where i got the idea to include polymer.js... that's weird. Perhaps something initially didn't work, but then worked once i included polymer and then i never fixed the issue properly or some such.

In the docs, very early it mentions including platform.js, then doesn't bother repeating its self (which is fine). So if you're allowed to both include platform.js and core-ajax.html, then it's fine and I'm just crazy.

Also sorry for the accusation... I wonder where the heck I got the idea that it suggested to use polymer.js... there is usually a reason why i do things... im very confused.

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