This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add 'domReady' method. This method can be used to access elements in …
…dom (descendants, ancestors, siblings) such that the developer is inured to upgrade ordering. If the element definitions have loaded, domReady can be used to access upgraded elements.
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>constructor test</title> | ||
<script src="../../../platform/platform.js"></script> | ||
<link rel="import" href="../../polymer.html"> | ||
<script src="../../../tools/test/htmltest.js"></script> | ||
<script src="../../../tools/test/chai/chai.js"></script> | ||
</head> | ||
<body> | ||
|
||
<x-foo></x-foo> | ||
<x-bar></x-bar> | ||
|
||
<polymer-element name="x-foo" constructor="XFoo"> | ||
<template> | ||
I am x-foo. | ||
</template> | ||
<script> | ||
(function() { | ||
var nog = function() {}; | ||
|
||
Polymer('x-foo', { | ||
created: function() { | ||
chai.assert.isTrue(this instanceof | ||
Object.getPrototypeOf(this).constructor); | ||
}, | ||
domReady: function() { | ||
chai.assert.isDefined(window.XFoo, 'constructor is undefined'); | ||
chai.assert.isTrue(CustomElements.instanceof(this, XFoo), 'instanceof failed'); | ||
chai.assert.isFalse(CustomElements.instanceof(this, nog), 'instanceof bugus base succeeded'); | ||
} | ||
}); | ||
})(); | ||
</script> | ||
</polymer-element> | ||
|
||
<polymer-element name="x-bar" extends="x-foo" constructor="XBar"> | ||
<template> | ||
I am x-bar. | ||
</template> | ||
<script> | ||
Polymer('x-bar', { | ||
created: function() { | ||
this.super(); | ||
chai.assert.isTrue(this instanceof | ||
Object.getPrototypeOf(this).constructor); | ||
}, | ||
domReady: function() { | ||
this.super(); | ||
chai.assert.isDefined(window.XBar, 'constructor is undefined'); | ||
//chai.assert.isTrue(this.impl instanceof XBar, 'instanceof failed'); | ||
chai.assert.isTrue(CustomElements.instanceof(this, XBar), 'instanceof failed'); | ||
done(); | ||
} | ||
}); | ||
</script> | ||
</polymer-element> | ||
</body> | ||
</html> |
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,45 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>domReady test</title> | ||
<script src="../../../platform/platform.js"></script> | ||
<link rel="import" href="../../polymer.html"> | ||
<script src="../../../tools/test/htmltest.js"></script> | ||
<script src="../../../tools/test/chai/chai.js"></script> | ||
</head> | ||
<body> | ||
|
||
<x-bar></x-bar> | ||
<x-foo> | ||
<x-bar></x-bar> | ||
</x-foo> | ||
<x-bar></x-bar> | ||
|
||
<polymer-element name="x-foo"> | ||
<template> | ||
I am x-foo. | ||
</template> | ||
<script> | ||
Polymer('x-foo', { | ||
fooish: true, | ||
domReady: function() { | ||
chai.assert.isTrue(this.firstElementChild.isBar, 'child is not upgraded'); | ||
chai.assert.isTrue(this.previousElementSibling.isBar, 'sibling is not upgraded'); | ||
chai.assert.isTrue(this.nextElementSibling.isBar, 'sibling is not upgraded'); | ||
done(); | ||
} | ||
}); | ||
</script> | ||
</polymer-element> | ||
|
||
<polymer-element name="x-bar"> | ||
<template> | ||
I am x-bar. | ||
</template> | ||
<script> | ||
Polymer('x-bar', { | ||
isBar: true | ||
}); | ||
</script> | ||
</body> | ||
</html> |
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