CaptionPanelImpl class
Implementation class without browser-specific hacks.
class CaptionPanelImpl {
factory CaptionPanelImpl.browserDependant() {
return new CaptionPanelImpl();
}
CaptionPanelImpl();
void setCaption(dart_html.FieldSetElement fieldset, dart_html.Element legend, String caption, [bool asHtml = true]) {
// TODO(bruce): rewrite to be inlinable
assert (caption != null);
if (asHtml) {
legend.innerHtml = caption;
} else {
legend.text = caption;
}
if ("" != caption) {
// This is formulated to become an append (if there's no widget), an
// insertion at index 0 (if there is a widget but no legend already), or
// a no-op (if the legend is already in place).
fieldset.insertBefore(legend, fieldset.firstChild);
} else if (legend.parent != null) {
// We remove the legend from the DOM because leaving it in with an empty
// string renders as an ugly gap in the top border on some browsers.
//fieldset.removeChild(legend);
legend.remove();
}
}
}
Subclasses
CaptionPanelImplMozilla, CaptionPanelImplSafari
Constructors
new CaptionPanelImpl() #
factory CaptionPanelImpl.browserDependant() #
factory CaptionPanelImpl.browserDependant() {
return new CaptionPanelImpl();
}
Methods
void setCaption(FieldSetElement fieldset, Element legend, String caption, [bool asHtml = true]) #
void setCaption(dart_html.FieldSetElement fieldset, dart_html.Element legend, String caption, [bool asHtml = true]) {
// TODO(bruce): rewrite to be inlinable
assert (caption != null);
if (asHtml) {
legend.innerHtml = caption;
} else {
legend.text = caption;
}
if ("" != caption) {
// This is formulated to become an append (if there's no widget), an
// insertion at index 0 (if there is a widget but no legend already), or
// a no-op (if the legend is already in place).
fieldset.insertBefore(legend, fieldset.firstChild);
} else if (legend.parent != null) {
// We remove the legend from the DOM because leaving it in with an empty
// string renders as an ugly gap in the top border on some browsers.
//fieldset.removeChild(legend);
legend.remove();
}
}