Skip to content

Commit

Permalink
Merge pull request #1618 from Polymer/1615-kschaaf
Browse files Browse the repository at this point in the history
Initialize _config with values set before creating accessors.
  • Loading branch information
Steve Orvell committed May 26, 2015
2 parents edb5e95 + 40089ff commit b0fa30a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
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

0 comments on commit b0fa30a

Please sign in to comment.