I'm adding a tab and a tab pane to a Bootstrap tab box in a custom element. Sometimes they appear, often they don't. Sometimes the pane appears but not the tab. The result is different on each reload. If it doesn't appear, causing a reflow by doing something like resizing the browser window or opening the Dartium inspector makes it suddenly appear.
I'm using Polymer 0.9.5. Here's the HTML:
<polymer-element name="confab-output-box">
<link rel="stylesheet" type="text/css" href="../resources/css/bootstrap.min.css">
<template bind>
<div id="output_container">
<ul id="tabs" class="nav nav-tabs">
</ul>
<div id="tab-content" class="tab-content">
</div>
</div>
</template>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="../resources/js/bootstrap.min.js"></script>
<script type="application/dart" src="confab_output_box.dart"></script>
</polymer-element>
and here's the Dart class:
library confab_output_box;
import 'dart:html';
import 'package:polymer/polymer.dart';
import '../confab_view/confab_view.dart';
@CustomTag('confab-output-box')
class ConfabOutputBox extends PolymerElement {
ConfabView activeView;
ConfabOutputBox.created() : super.created();
void attachView(ConfabView view) {
$['tabs'].children.add(
new LIElement()
..id = '${view.id}-tab'
..children.add(
new AnchorElement()
..href = '#${view.id}'
..onClick.listen(tabClicked)
..text = view.tabTitle
)
);
$['tab-content'].children.add(view..classes.add('tab-pane'));
}
void detachView(ConfabView view) {
shadowRoot.getElementById('${view.id}-tab').remove();
shadowRoot.getElementById(view.id).remove();
}
void activateView(ConfabView view) {
if (activeView != null) {
shadowRoot.getElementById('${activeView.id}-tab').classes.remove('active');
shadowRoot.getElementById(activeView.id).classes.remove('active');
}
shadowRoot.getElementById('${view.id}-tab').classes.add('active');
shadowRoot.getElementById(view.id).classes.add('active');
activeView = view;
}
void tabClicked(Event e) {
e.preventDefault();
ConfabView view = shadowRoot.querySelector((e.toElement as AnchorElement).href);
activateView(view);
}
}