2016-04-18 5 views
0

diesen Code vor:Warum wird die HTML aus Vorlage dom-wenn nicht hier angewendet bekommen

<div class="container"> 
    <table class="c"> 
     <tr> 
     <template is="dom-repeat" items="[[days]]" as="o"> 
      <td class$="[[dayClass(o)]]"><span class="d">[[formatDay(o)]]</span></td> 
      <template is="dom-if" if="[[lastDayOfWeek(o)]]"></tr> 
       <template is="dom-if" if="[[!lastDayOfCalendar(o)]]"><tr></template> 
      </template> 
     </template> 
     </tr> 
    </table> 
</div> 

Warum die </tr> und <tr> nicht auf die html angewendet werden?

Voll JS Bin Demo hier: https://jsbin.com/dujekefoga/edit?html,output

Edit: Feste JS Bin url

Antwort

0

Am Ende ist das, was funktioniert. Und ich glaube, es ist die beste Lösung, da es mit zwei nicht verschachtelten dom-if arbeitet, und das HTML ist gültig.

Ich musste nur eine Funktion firstDayOfWeek hinzufügen, die wahr zurückgibt, wenn item.isoWeekday() === 1.

<template is="dom-repeat" items="[[days]]" as="o"> 
     <template is="dom-if" if="[[firstDayOfWeek(o)]]"><tr></template> 
     <td class$="[[dayClass(o)]]"><span class="d">[[formatDay(o)]]</span></td> 
     <template is="dom-if" if="[[lastDayOfWeek(o)]]"></tr></template> 
    </template>