Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Unified Diff: pkg/polymer/test/register_test.dart

Issue 290113002: [polymer] add a new API to create an element without polymer-element in HTML (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/src/instance.dart ('k') | pkg/polymer/test/register_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/register_test.dart
diff --git a/pkg/polymer/test/register_test.dart b/pkg/polymer/test/register_test.dart
index f5f2bda89014da5bbc924db49ced9881340a1569..c0ab7d3967e67371e4a82904e4ee56ea1379722a 100644
--- a/pkg/polymer/test/register_test.dart
+++ b/pkg/polymer/test/register_test.dart
@@ -3,9 +3,9 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:html';
+import 'package:polymer/polymer.dart';
import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
-import 'package:polymer/polymer.dart';
@CustomTag('x-html')
class XHtmlElement extends PolymerElement {
@@ -27,6 +27,19 @@ class XDiv2Element extends XDivElement {
XDiv2Element.created() : super.created();
}
+/// Dart-specific test:
+/// This element is registered from code without an associated polymer-element.
+class XPolymerElement extends PolymerElement {
+ XPolymerElement.created() : super.created();
+}
+
+/// Dart-specific test:
+/// This element is registered from code without an associated polymer-element.
+class XButtonElement extends ButtonElement with Polymer, Observable {
+ XButtonElement.created() : super.created();
+}
+
+
@initMethod
main() {
useHtmlConfiguration();
@@ -39,4 +52,30 @@ main() {
expect(querySelector('#x-div') is XDivElement, isTrue);
expect(querySelector('#x-div-two') is XDiv2Element, isTrue);
});
+
+ group('register without polymer-element', () {
+ test('custom element', () {
+ Polymer.registerSync('x-polymer', XPolymerElement,
+ template: new Element.html('<template>FOOBAR'));
+
+ expect(document.createElement('x-polymer') is XPolymerElement, isTrue,
+ reason: 'should have been registered');
+
+ var e = document.querySelector('x-polymer');
+ expect(e is XPolymerElement, isTrue,
+ reason: 'elements on page should be upgraded');
+ expect(e.shadowRoot, isNotNull,
+ reason: 'shadowRoot was created from template');
+ expect(e.shadowRoot.nodes[0].text, 'FOOBAR');
+ });
+
+ test('type extension', () {
+ Polymer.registerSync('x-button', XButtonElement, extendsTag: 'button');
+
+ expect(document.createElement('button', 'x-button') is XButtonElement,
+ isTrue, reason: 'should have been registered');
+ expect(document.querySelector('[is=x-button]') is XButtonElement, isTrue,
+ reason: 'elements on page should be upgraded');
+ });
+ });
}
« no previous file with comments | « pkg/polymer/lib/src/instance.dart ('k') | pkg/polymer/test/register_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698