PolymerElements / iron-component-page

A reusable landing page for elements
36 stars 32 forks source link

JSON.parse() fails for asciidoctor comments #58

Open kito99 opened 9 years ago

kito99 commented 9 years ago

I wonder if iron-components-page should perhaps strip out comments when it tries to parse an HTML file. I'm using Asciidoctor to generate labs from HTML files, and it chokes on the standard Asciidoc identifiers for code snippets. For example:


<!-- tag::body[] -->
<body unresolved>   <!--1-->
      <h1>Hacking Web Components: Polymer Deluxe Counter</h1>
      <iron-component-page src="deluxe-counter.html"</iron-component-page>  <!--2-->
  </div>
</paper-header-panel>
</body>
<!-- end::body[] -->

This snippet chokes in JSON.parse() in iron-component-page.html:


    _loadJson: function() {
...
        var json = JSON.parse(textContent);
    },

Full stack trace:

 end::body[] SyntaxError: Unexpected token e(…)Polymer._loadJson @ iron-component-page.html:281Polymer.ready @ iron-component-page.html:250Polymer.Base._addFeature._invokeBehavior @ polymer-micro.html:356Polymer.Base._addFeature._doBehavior @ polymer-micro.html:351Polymer.Base._addFeature._readySelf @ polymer-mini.html:80Polymer.Base._addFeature._ready @ polymer-mini.html:67Polymer.Base._addFeature._tryReady @ polymer-mini.html:56Polymer.Base._addFeature._initFeatures @ polymer.html:3221Polymer.Base.createdCallback @ polymer-micro.html:151
iron-component-page.html:277 Uncaught SyntaxError: Unexpected token ePolymer._loadJson @ iron-component-page.html:277Polymer.ready @ iron-component-page.html:250Polymer.Base._addFeature._invokeBehavior @ polymer-micro.html:356Polymer.Base._addFeature._doBehavior @ polymer-micro.html:351Polymer.Base._addFeature._readySelf @ polymer-mini.html:80Polymer.Base._addFeature._ready @ polymer-mini.html:67Polymer.Base._addFeature._tryReady @ polymer-mini.html:56Polymer.Base._addFeature._initFeatures @ polymer.html:3221Polymer.Base.createdCallback @ polymer-micro.html:151
cdata commented 8 years ago

This smells like an escaping problem.

cdata commented 8 years ago

Can you provide a reduced test case to demonstrate the problem?