Permalink
Browse files

bug: Notification-Dialog overwrites default DomRenderer

  • Loading branch information...
MikeMitterer committed Feb 18, 2016
1 parent 14c5a0b commit 7e0acb605add794cddc1f3348ad46cb035ab2ab4
@@ -45,6 +45,10 @@ class DomRenderer {
final List<_DomRenderFunction> _renderFunctions = new List<_DomRenderFunction>();
DomRenderer() {
_logger.info("CTOR for DomRenderer");
}
/// Renders the {content} String into the given {parent} - {content} must have ONE! top level element.
/// If {replaceNode} is false {content} will be added to {parent} otherwise th new
/// {content} replaces the old content
@@ -54,7 +58,7 @@ class DomRenderer {
Validate.notNull(parent);
Validate.notBlank(content);
_logger.fine("Start with rendering process...");
_logger.info("Start with rendering process...");
final Completer completer = new Completer();
@@ -79,7 +83,7 @@ class DomRenderer {
componentHandler().downgradeElement(oldElement);
}
oldElement.remove();
//_logger.info("Old element removed!");
_logger.info("Old element removed!");
}
//element.append(child);
@@ -149,7 +149,8 @@ abstract class MaterialDialog extends Object with TemplateComponent, MdlEventLis
}
// Now - add the template into the _dialogContainer
_renderer.render().then( (_) {
//_renderer.render().then( (_) {
_render().then( (_) {
// _autoIncrementID must be on top of this block! - will be used by _elementID
_autoIncrementID = idCounter;
@@ -384,12 +385,10 @@ abstract class MaterialDialog extends Object with TemplateComponent, MdlEventLis
eventStreams.clear();
}
Renderer get _renderer {
Future _render() {
final TemplateRenderer templateRenderer = componentFactory().injector.get(TemplateRenderer);
templateRenderer.appendNewNodes = _config.appendNewDialog;
final Renderer renderer = templateRenderer.call(_dialogContainer,this,() => template);
return renderer;
return templateRenderer.render(_dialogContainer,this,
() => template,replaceNode: !_config.appendNewDialog);
}
}
@@ -57,9 +57,11 @@ abstract class MdlTemplateComponent extends MdlComponent implements TemplateComp
}
Future render() {
return _renderer.render();
final TemplateRenderer templateRenderer = injector.get(TemplateRenderer);
return templateRenderer.render(element,this,() => template);
}
@deprecated
void set renderer(final Renderer renderer) {
Validate.notNull(renderer);
_renderer = renderer;
@@ -33,8 +33,11 @@ class TemplateRenderer {
/// the new one.
bool appendNewNodes = false;
TemplateRenderer(this._renderer, this._eventCompiler);
TemplateRenderer(this._renderer, this._eventCompiler) {
_logger.info("TemplateRenderer CTOR");
}
@deprecated
Renderer call(final dom.Element parent,final Object scope, String template() ) {
Validate.notNull(parent);
Validate.notNull(scope);
@@ -63,6 +66,26 @@ class TemplateRenderer {
return new Renderer(_render);
}
Future render(final dom.Element parent, final Object scope, String template(),{ final bool replaceNode: true}) async {
Validate.notNull(parent);
Validate.notNull(scope);
/// Trims the template and replaces multiple spaces with a single space
String _template() {
final String data = template();
Validate.notNull(data,"Template for TemplateRenderer must not be null!!!!");
return data.trim().replaceAll(new RegExp(r"\s+")," ");
}
final Template mustacheTemplate = new Template(_template(),htmlEscapeValues: false);
// _renderer.render calls componentFactory().upgradeElement(child)
final String renderedTemplate = mustacheTemplate.renderString(scope);
final dom.Element child = await _renderer.render(parent,renderedTemplate,replaceNode: replaceNode);
return _eventCompiler.compileElement(scope,child);
}
// - private ----------------------------------------------------------------------------------

0 comments on commit 7e0acb6

Please sign in to comment.