| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:html'; | 6 import 'dart:html'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'package:unittest/html_config.dart'; | 8 import 'package:unittest/html_config.dart'; |
| 9 import 'package:polymer/polymer.dart'; | 9 import 'package:polymer/polymer.dart'; |
| 10 | 10 |
| 11 @CustomTag('x-target') | 11 @CustomTag('x-target') |
| 12 class XTarget extends PolymerElement { | 12 class XTarget extends PolymerElement { |
| 13 XTarget.created() : super.created(); |
| 14 |
| 13 final Completer _found = new Completer(); | 15 final Completer _found = new Completer(); |
| 14 Future get foundSrc => _found.future; | 16 Future get foundSrc => _found.future; |
| 15 | 17 |
| 16 // force an mdv binding | 18 // force an mdv binding |
| 17 bind(name, model, path) => | 19 bind(name, model, path) => |
| 18 TemplateElement.mdvPackage(this).bind(name, model, path); | 20 TemplateElement.mdvPackage(this).bind(name, model, path); |
| 19 | 21 |
| 20 inserted() { | 22 inserted() { |
| 21 testSrcForMustache(); | 23 testSrcForMustache(); |
| 22 } | 24 } |
| 23 | 25 |
| 24 attributeChanged(name, oldValue) { | 26 attributeChanged(name, oldValue, newValue) { |
| 25 testSrcForMustache(); | 27 testSrcForMustache(); |
| 26 if (attributes[name] == '../testSource') { | 28 if (attributes[name] == '../testSource') { |
| 27 _found.complete(); | 29 _found.complete(); |
| 28 } | 30 } |
| 29 } | 31 } |
| 30 | 32 |
| 31 testSrcForMustache() { | 33 testSrcForMustache() { |
| 32 expect(attributes['src'], isNot(matches(Polymer.bindPattern)), | 34 expect(attributes['src'], isNot(matches(Polymer.bindPattern)), |
| 33 reason: 'attribute does not contain {{...}}'); | 35 reason: 'attribute does not contain {{...}}'); |
| 34 } | 36 } |
| 35 } | 37 } |
| 36 | 38 |
| 37 @CustomTag('x-test') | 39 @CustomTag('x-test') |
| 38 class XTest extends PolymerElement { | 40 class XTest extends PolymerElement { |
| 41 XTest.created() : super.created(); |
| 42 |
| 39 @observable var src = 'testSource'; | 43 @observable var src = 'testSource'; |
| 40 } | 44 } |
| 41 | 45 |
| 42 main() { | 46 main() { |
| 43 useHtmlConfiguration(); | 47 useHtmlConfiguration(); |
| 44 | 48 |
| 45 test('mustache attributes', () { | 49 test('mustache attributes', () { |
| 46 final xtest = document.query('#test').xtag; | 50 final xtest = document.query('#test').xtag; |
| 47 final xtarget = xtest.shadowRoot.query('#target').xtag; | 51 final xtarget = xtest.shadowRoot.query('#target').xtag; |
| 48 return xtarget.foundSrc; | 52 return xtarget.foundSrc; |
| 49 }); | 53 }); |
| 50 } | 54 } |
| OLD | NEW |