Skip to content
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

Unbinding a model does not completely make the template's contents disappear #11983

Closed
sethladd opened this issue Jul 23, 2013 · 7 comments
Closed
Labels
closed-duplicate Closed in favor of an existing report

Comments

@sethladd
Copy link
Contributor

Consider this code:

<!DOCTYPE html>

<html>
  <head>
    <title>index</title>
  </head>
 
  <body>
    <p>
      The below will appear and disappear as a model object is
      bound and unbound from the template. Conditionals are implemented
      simply as "this template appears if something is bound" and
      "this template disappears if nothing is bound".
    </p>
    
    <template id="tmpl" bind>
      <p>Hello {{msg}}</p>
    </template>
    
    <script type="application/dart" src="index.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>

import 'dart:html';
import 'package:mdv/mdv.dart' as mdv;
import 'dart:async';

class Message {
  String msg;
}

main() {
  mdv.initialize();
  
  var message = new Message()..msg = 'world';
  var template = query('#tmpl');
  
  new Timer.periodic(const Duration(seconds: 1), (_) {
    if (template.model != null) {
      template.model = null;
    } else {
      template.model = message;
    }
  });
  
}

My understanding is that, if no model is bound to the template, the contents of the template disappear from the DOM.

However, I only see 'world' appear and disappear. For the first second, I don't see 'Hello'. After one second, I see 'Hello, World', then 'Hello' then 'Hello World' etc

Bug?

@jmesserly
Copy link

it sure sounds like a bug. will need to double check against the JS version, as well as our bleeding_edge version (which contains many fixes since last pkg release)

@sethladd
Copy link
Contributor Author

Apologies, I should have included this info:

Dart Editor version 0.6.5_r25017

  mdv:
    description: mdv
    source: hosted
    version: "0.6.5"

  polymer:
    description: polymer
    source: hosted
    version: "0.5.0+1"

@sethladd
Copy link
Contributor Author

FWIW I still see the bug.

 I updated to Dart Editor version 0.6.9_r25388
 and

  polymer:
    description: polymer
    source: hosted
    version: "0.5.1"

  mdv:
    description: mdv
    source: hosted
    version: "0.6.9+2"

@jmesserly
Copy link

yeah, I don't think any significant changes were picked up yet... that build is from Friday, all my catch-up CL's including the one that changes setting model, landed this week. let me try against bleeding edge.

@jmesserly
Copy link

I was able to reproduce it in JavaScript. Moving issue over to MDV tracker:
googlearchive/TemplateBinding#128


Added MovedToGithub label.

@sethladd
Copy link
Contributor Author

Thanks for taking a look!

@sethladd
Copy link
Contributor Author

This behavior now works in polymer.js. I opened https://code.google.com/p/dart/issues/detail?id=12687 to track the port to polymer.dart


Added Duplicate label.
Marked as being merged into #12687.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

3 participants