forked from dart-archive/polymer-dart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dart-archive#52 from dart-lang/when-polymer-ready
added @whenPolymerReady which will invoke a function once polymer is ready
- Loading branch information
Showing
8 changed files
with
100 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
part of polymer; | ||
|
||
/// Automatically registers a polymer element. | ||
class CustomTag implements Initializer<Type> { | ||
final String tagName; | ||
const CustomTag(this.tagName); | ||
|
||
@override | ||
initialize(Type t) => Polymer.register(tagName, t); | ||
} | ||
|
||
/// Calls a zero argument [Function] after [Polymer.onReady] completes. | ||
typedef dynamic _ZeroArg(); | ||
class _WhenPolymerReady implements Initializer<_ZeroArg> { | ||
const _WhenPolymerReady(); | ||
|
||
@override | ||
void initialize(_ZeroArg f) { | ||
Polymer.onReady.then((_) => f()); | ||
} | ||
} | ||
|
||
const whenPolymerReady = const _WhenPolymerReady(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: polymer | ||
version: 0.16.0+7 | ||
version: 0.16.1 | ||
author: Polymer.dart Authors <[email protected]> | ||
description: > | ||
Polymer.dart is a new type of library for the web, built on top of Web | ||
|
@@ -80,6 +80,7 @@ transformers: | |
- test/two_way_bind_test.html | ||
- test/unbind_test.html | ||
- test/web_components_less_test.html | ||
- test/when_polymer_ready_test.html | ||
|
||
environment: | ||
sdk: '>=1.4.0 <2.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
library polymer.test.when_polymer_ready_test; | ||
|
||
import 'dart:async'; | ||
import 'dart:html'; | ||
|
||
import 'package:polymer/polymer.dart'; | ||
import 'package:unittest/unittest.dart'; | ||
import 'package:unittest/html_config.dart'; | ||
|
||
final Completer done = new Completer(); | ||
|
||
@CustomTag('x-a') | ||
class XA extends PolymerElement { | ||
XA.created() : super.created(); | ||
} | ||
|
||
main() { | ||
useHtmlConfiguration(); | ||
|
||
test('whenPolymerReady functions get called when polymer is ready', () { | ||
expect(querySelector('x-a') is XA, isFalse); | ||
initPolymer(); | ||
return done.future; | ||
}); | ||
} | ||
|
||
@whenPolymerReady | ||
void whenReady() { | ||
expect(querySelector('x-a') is XA, isTrue); | ||
done.complete(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!doctype html> | ||
<!-- | ||
Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | ||
for details. All rights reserved. Use of this source code is governed by a | ||
BSD-style license that can be found in the LICENSE file. | ||
--> | ||
<html> | ||
|
||
<head> | ||
<title>whenPolymerReady</title> | ||
<script src="packages/unittest/test_controller.js"></script> | ||
</head> | ||
<body> | ||
|
||
<x-a></x-a> | ||
|
||
<polymer-element name="x-a"><template>hello!</template></polymer-element> | ||
|
||
<script type="application/dart" src="when_polymer_ready_test.dart"></script> | ||
</body> | ||
</html> |