Skip to content

Commit

Permalink
Fixes #2098: don't accept undefined values as initial config
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Jul 17, 2015
1 parent 3d56eb0 commit 1a5c391
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/standard/configure.html
Expand Up @@ -45,7 +45,13 @@

// storage for configuration
_setupConfigure: function(initialConfig) {
this._config = initialConfig || {};
this._config = {};
// don't accept undefined values in intialConfig
for (var i in initialConfig) {
if (initialConfig[i] !== undefined) {
this._config[i] = initialConfig[i];
}
}
this._handlers = [];
},

Expand Down Expand Up @@ -92,6 +98,7 @@
_configureProperties: function(properties, config) {
for (var i in properties) {
var c = properties[i];
// don't accept undefined values
if (c.value !== undefined) {
var value = c.value;
if (typeof value == 'function') {
Expand Down
68 changes: 68 additions & 0 deletions test/smoke/bind-smoke2.html
@@ -0,0 +1,68 @@
<!doctype html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../polymer.html">

<body>

<dom-module is="data-source">
<template>
<span>{{prop}}</span>
<span>{{data.length}}</span>: length
<br>

<template is="dom-repeat" items="{{data}}">
<span>{{item}}</span>
</template>:items
</template>
</dom-module>


<script>
Polymer({
is: 'data-source',

properties: {
data: {
//readOnly: true,
notify: true,
type: Array,
value: [1, 2, 3]
},

prop: {
readOnly: true,
notify: true,
type: String,
value: 'foo'
}
}
});
</script>


<template is="dom-bind">

<h1>Element</h1>
<data-source data="{{data}}" prop="{{prop}}"></data-source>

<h1>Databound</h1>

<span>{{prop}}</span>

<template is="dom-repeat" items="{{data}}">
<span>{{item}}</span>
</template>

</template>



</body>
12 changes: 12 additions & 0 deletions test/unit/dom-bind-elements1.html
Expand Up @@ -7,4 +7,16 @@
}
}
});
</script>

<script>
Polymer({
is: 'x-produce-a',
properties: {
a: {
notify: true,
value: 'a'
}
}
});
</script>
7 changes: 7 additions & 0 deletions test/unit/dom-bind.html
Expand Up @@ -30,6 +30,8 @@
<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>
<x-produce-a a={{z}}></x-produce-a>
<div id="z">{{z}}</div>
</template>

<div id="container">
Expand Down Expand Up @@ -90,6 +92,11 @@
assert.equal(el1.computed, 50);
});

test('initial value notifies to dom-bind', function() {
assert.equal(domBind.z, 'a');
assert.equal(z.textContent, 'a');
});

});

suite('imperative dom-bind', function() {
Expand Down

0 comments on commit 1a5c391

Please sign in to comment.