message: Updated flatten logic and arity more intention-revealing.
diff: @@ -222,8 +222,11 @@ Vulcan.prototype = {
  isInsideTemplate: dom5.predicates.parentMatches(
  dom5.predicates.hasTagName('template')),
  - flatten: function flatten(tree, rootDocPath) {
  - var isMainDoc = tree.href === rootDocPath;
  + flatten: function flatten(tree, mainDocUrl) {
  + var isMainDoc = (mainDocUrl === undefined);
  + if (isMainDoc) {
  + mainDocUrl = tree.href;
  + }
  var doc = tree.html.ast;
  var imports = tree.imports;
  var head = dom5.query(doc, matchers.head);
  @@ -277,7 +280,7 @@ Vulcan.prototype = {
  continue;
  }
  var bodyFragment = dom5.constructors.fragment();
  - var importDoc = this.flatten(im, rootDocPath);
  + var importDoc = this.flatten(im, mainDocUrl);
  // rewrite urls
  this.pathResolver.resolvePaths(importDoc, im.href, tree.href);
  var importHead = dom5.query(importDoc, matchers.head);
  @@ -460,7 +463,7 @@ Vulcan.prototype = {
  chain = chain.then(function(){
  return analyzer.metadataTree(target);
  }).then(function(tree) {
  - var flatDoc = this.flatten(tree, tree.href);
  + var flatDoc = this.flatten(tree);
  // make sure there's a <meta charset> in the page to force UTF-8
  var meta = dom5.query(flatDoc, matchers.meta);
  var head = dom5.query(flatDoc, matchers.head);
  