New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
template_binding doesn't clear nested templates on Safari #19109
Comments
I should add that I tried to reproduce this in Polymer.js and couldn't. |
Removed Area-Polymer label. |
So it looks like this is caused by the document not being bootstrapped when loaded. Adding: TemplateBindExtension.bootstrap(document); to main() of the repro fixes the problem. The lazy calls to _decorate() do not fix the problem, because in the polyfill _decorate() does not call bootstrap() it calls _liftNonNativeChildrenIntoContent(), and bootstrap is what recurses into nested templates. This is why only nested templates don't have their contents removed. So another fix is to have _decorate() call bootstrap() even for non-native templates. This change also fixes the bug: Original, in TemplateBindExtension._decorate(): if (instanceRef != null) { Fix: if (instanceRef != null) { This does not match the JS version at: https://github.com/Polymer/TemplateBinding/blob/master/src/TemplateBinding.js#L392 but, they have already called bootstrap on all templates that were in the document on load, where we haven't. So I see a few different fixes:
cc @sigmundch. |
Added this to the 1.6 milestone. |
Removed this from the 1.6 milestone. |
Removed Polymer-P-1 label. |
Added PolymerMilestone-Next label. |
Removed Polymer-Milestone-Next label. |
Added this to the 1.6 milestone. |
Removed this from the 1.6 milestone. |
Added this to the 1.6 milestone. |
Removed this from the 1.6 milestone. |
Removed Priority-High label. |
nowadays, i think the fix would be to use the initialization package Jake is working on ... that would give us a standardized way to perform the bootstrap. However ... here's the thing ... if you've loaded the JS version of template_binding.js, you already got this fix "for free" because it will bootstrap the page. So polymer apps are currently immune (they always have polymer.js 0.5.x) ... and if we fix https://code.google.com/p/dart/issues/detail?id=18893 it won't be needed. going to dupe this against that bug. cc @jakemac53. |
This might ultimately be the cause of https://code.google.com/p/dart/issues/detail?id=16568
In Safari only (maybe IE, but not Firefox), a nested template is not cleared out, and it's bindings are evaluated. The template is hidden with display: none, which is probably why we haven't gotten any reports of this yet.
Here's a minimal reproduction:
index.dart:
import 'dart:html';
import 'package:template_binding/template_binding.dart';
import 'package:smoke/mirrors.dart';
main() {
useMirrors();
var template = templateBind(querySelector("#test")).model = new Model();
}
class Model {
String data = 'bar';
}
index.html:
<!DOCTYPE html>
<html>
<body>
<template id="test" bind>
<div>{{ data }}</div>
<template bind="{{ data }}" id="inner">
<div>{{ }}</div>
</template>
</template>
<script type="application/dart" src="polyfill_test.dart"></script>
<script src="packages/browser/dart.js"></script>
</body>
</html>
The nested template #inner will have content of <div>Instance of 'Model'</div>, when it should be empty.
The text was updated successfully, but these errors were encountered: