Vulcanize, polymer.js, and HierarchyRequestError

206 views
Skip to first unread message

Andrew Fallows

unread,
Jan 6, 2015, 1:30:20 PM1/6/15
to polym...@googlegroups.com
After looking at a few threads here and a few issues on the Polymer GitHub repo, it looks like getting an error of 

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

after vulcanizing a polymer application is usually a sign that polymer.js is getting sourced more than once. However, I'm having a hard time figuring out whether that's true for my project.

I'm working on a project which uses a lot of custom components, and has a pretty long import hierarchy:

  • foo-app
    • foo-header
    • foo-page-one
      • foo-hero-unit
      • foo-table
    • foo-page-two
      • foo-hero-unit
      • foo-slideshow
    • foo-footer
Each of these components imports polymer with a <link rel="import" href="../polymer/polymer.html"> -- however, vulcanize appears to be successfully eliminating multiple import (foo-hero-unit doesn't get imported twice), so I would expect polymer to only get imported once. I'm not sure how to confirm whether it is.

What should my next debugging steps be? I'm happy to provide more information, too, but since this is a closed source application, that does have some unfortunate limitations.

The full HTML of the file I'm vulcanizing is below.

Thanks,
Andrew Fallows

<!doctype html>
<html>
  <head>

    <meta
      name="viewport"
      content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
    <title>Project Foo</title>
    <link rel="stylesheet" href="../assets/foo/base.css">
    <script src="../assets/webcomponentsjs/webcomponents.js"></script>
    <link rel="import" href="../assets/foo-app/foo-app.html">

  </head>

  <body unresolved>
      <foo-app></foo-app>
  </body>
</html>

Eric Bidelman

unread,
Jan 6, 2015, 1:43:30 PM1/6/15
to Andrew Fallows, polymer-dev
What is the vulcanize command you're running?

To check if polymer.js is being loaded more than once, open the vulcanized output and check for "polymer.js" or the inlined file (if you're running --inline).

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/9f8ecff0-5855-41eb-bea3-25f646b376a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Fallows

unread,
Jan 6, 2015, 1:50:14 PM1/6/15
to Eric Bidelman, polymer-dev
I was using gulp-vulcanize to execute the inlining; with both inline and strip turned on.

I turned off both options so I could more easily check if polymer appeared more than once. It doesn't appear to -- with inlining disabled, I get one instance of 

<script src="assets/polymer/polymer.js"></script>

My full gulp task is below

module.exports = function(gulp, paths, helpers) {
  gulp.task('vulcanize', function() {
    var dest       = './public';
    var viewFile   = './app/views/polymer/index.html';
    var publicFile = './public/assets/index.html';

    fs.createReadStream(viewFile).pipe(fs.createWriteStream(publicFile));

    return gulp.src(publicFile)
      .pipe(vulcanize({
        dest: dest,
        inline: false,
        strip: false
      }))
      .pipe(gulp.dest(dest));
  });
};


To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev+unsubscribe@googlegroups.com.

Eric Bidelman

unread,
Jan 6, 2015, 3:31:20 PM1/6/15
to Andrew Fallows, polymer-dev
Gulp vulcanize is using vulcanize 0.7.1 The latest vulcanize is 0.7.5 Can you try running the latest version directly and see if that makes a difference?

Andrew Fallows

unread,
Jan 6, 2015, 3:38:19 PM1/6/15
to polym...@googlegroups.com, kald...@gmail.com
That does indeed fix it! I guess that means I should push for gulp-vulcanize to update its dependent version.

Thanks for the help, Eric. You rock.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.

Eric Bidelman

unread,
Jan 6, 2015, 4:25:27 PM1/6/15
to Andrew Fallows, polymer-dev
Np. If you submit a PR to them, everyone (including myself) will be greatly appreciative :)

Andrew Fallows

unread,
Jan 7, 2015, 9:18:40 AM1/7/15
to Eric Bidelman, polymer-dev
I opened a PR, but it turns out it wasn't needed: https://github.com/sindresorhus/gulp-vulcanize/pull/16#issuecomment-69025708

For future reference: https://nodesource.com/blog/semver-tilde-and-caret

I was able to get gulp-vulcanize to use vulcanize 0.7.5 simply by reinstalling gulp-vulcanize
Reply all
Reply to author
Forward
0 new messages