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

Initialize _config with values set before creating accessors. #1618

Merged
merged 2 commits into from
May 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/lib/template/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,22 @@
}
},

_prepConfigure: function() {
var config = {};
for (var prop in this._propertyEffects) {
config[prop] = this[prop];
}
// Pass values set before attached as initialConfig to _setupConfigure
this._setupConfigure = this._setupConfigure.bind(this, config);
},

attached: function() {
if (!this._children) {
this._template = this;
this._prepAnnotations();
this._prepEffects();
this._prepBehaviors();
this._prepConfigure();
this._prepBindings();
Polymer.Base._initFeatures.call(this);
this._children = Array.prototype.slice.call(this.root.childNodes);
Expand Down
21 changes: 19 additions & 2 deletions test/unit/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../polymer.html">
<link rel="import" href="dom-bind-elements1.html">
</head>
<body>

<template is="dom-bind" id="earlyDomBind">
<div id="earlyBoundChild">{{value}}</div>
</template>

<script>
earlyDomBind.value = 'hi!';
</script>

<link rel="import" href="../../polymer.html">
<link rel="import" href="dom-bind-elements1.html">

<template is="dom-bind" id="decDomBind">
<x-basic id="decEl1" value="{{value}}" notifyingvalue="{{nvalue}}" on-custom="handleEvent" computed="{{compute(dep)}}"></x-basic>
<x-basic id="decEl2" value="{{value}}" notifyingvalue="{{nvalue}}"></x-basic>
Expand All @@ -32,6 +41,14 @@

<script>

suite('dom-bind touched before upgrade', function() {

test('value binds top-down', function() {
assert.equal(earlyBoundChild.textContent, 'hi!');
});

});

suite('declarative dom-bind', function() {

var domBind;
Expand Down