Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngTransclude on table element inserts illegal markup #3241

Closed
mklew opened this issue Jul 16, 2013 · 2 comments
Closed

ngTransclude on table element inserts illegal markup #3241

mklew opened this issue Jul 16, 2013 · 2 comments

Comments

@mklew
Copy link

mklew commented Jul 16, 2013

Issue originated from my question
https://groups.google.com/forum/#!topic/angular/eqGcOcQMAt4

On the first plnkr you see that when ngRepeat is used within table element without ngTransclude then everything works fine.

Here you can see that it works when there is no transclusion on 'mmtable' directive and ngRepeat is part of its template. Also 'mmtable' priority has been changed so that it compiles before ngRepeat.

ngTransclude inserts illegal markup inside table element. Concretely it inserts span element. Template becomes weird and ngRepeat doesn't work.

<table table="" class="table table-stripped table-bordered table-hover ng-isolate-scope ng-scope" props="props" service="service" expose-as="exposeAs" ng-transclude="">


            <!-- this for some reason does not work --><span class="ng-scope ng-binding">




    </span></table>

Kind regards to BahamutWC for pointing out that this is really bug.

@caitp caitp closed this as completed in 31c450b Feb 14, 2014
khepin pushed a commit to khepin/angular.js that referenced this issue Feb 19, 2014
If the first element in a template is a <tr>, <th>, <td>, or <tbody> tag,
the HTML compiler will ensure that the template is wrapped in a <table>
element so that the table content is not discarded.

Closes angular#2848
Closes angular#1459
Closes angular#3647
Closes angular#3241
@carlos-algms
Copy link

But if the first element is thead

<my-directive>
  <thead>. . . </thead>
</my-directive>

The bug still persist

@jordajm
Copy link

jordajm commented Mar 26, 2016

@carlos-algms - I was having the same issue until I realized that it wasn't actually an angular bug - the browser was just interpreting the lack of <table> tags around the <thead> and <tbody> as bad markup and handling it before Angular had a chance to render the <table> tag from the directive's template.

To fix it, you could either nest the <table> tag inside the directive element or use the directive as an attribute on the <table> tag like this: <table my-directive>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants