1

I discovered something strange. In angular 2 component something like this doesn't work:

<p>
  AAA
  <ul>
    <li>BBB</li>
  </ul>
</p>

Why? (I believe this is valid HTML)

(if I move </p> before <ul> everything will be fine)

I get strange error:

errors.js:64 Uncaught TypeError: Cannot set property 'stack' of undefined at SyntaxError.set [as stack] (http://localhost:4200/vendor.bundle.js:66369:61) at assignAll (http://localhost:4200/vendor.bundle.js:100568:29) at SyntaxError.ZoneAwareError (http://localhost:4200/vendor.bundle.js:100639:16) at SyntaxError.BaseError [as constructor] (http://localhost:4200/vendor.bundle.js:66331:16) at new SyntaxError (http://localhost:4200/vendor.bundle.js:6861:16) at DirectiveNormalizer.normalizeLoadedTemplate (http://localhost:4200/vendor.bundle.js:17962:19) at DirectiveNormalizer.normalizeTemplateSync (http://localhost:4200/vendor.bundle.js:17939:21) at DirectiveNormalizer.normalizeTemplate (http://localhost:4200/vendor.bundle.js:17916:43) at CompileMetadataResolver._loadDirectiveMetadata (http://localhost:4200/vendor.bundle.js:19158:75) at http://localhost:4200/vendor.bundle.js:19334:54 at Array.forEach (native) at CompileMetadataResolver.loadNgModuleDirectiveAndPipeMetadata (http://localhost:4200/vendor.bundle.js:19333:41) at http://localhost:4200/vendor.bundle.js:47800:58 at Array.forEach (native) at JitCompiler._loadModules (http://localhost:4200/vendor.bundle.js:47799:43)

Extra question: Is there any way to define where is the error in this message?

tBlabs
  • 2,619
  • 3
  • 18
  • 22
  • Looks like chrispy has the answer right but in terms of your errors, downgrading zone version down to v0.7.4 helped make all those useless html template related errors turn into useful errors – Joshua Ohana Jan 21 '17 at 01:57
  • good idea ohana -- I have not messed with zone much, so that is a good tip if it's giving better errors (sometimes ng2 is vague) – chrispy Jan 21 '17 at 02:01

1 Answers1

5

According to the HTML spec, I don't think you can put <ul> elements inside <p> elements -- see here:

Should ol/ul be inside <p> or outside?

I think Angular 2 does not expect this case as it is not valid HTML, so it breaks.

Community
  • 1
  • 1
chrispy
  • 3,552
  • 1
  • 11
  • 19