Skip to content
Browse files

Fixes #2098: don't accept undefined values as initial config

  • Loading branch information...
1 parent 3d56eb0 commit 1a5c391b7d0d037c48d243763ec0602c5611678b @sorvell sorvell committed
Showing with 95 additions and 1 deletion.
  1. +8 −1 src/standard/configure.html
  2. +68 −0 test/smoke/bind-smoke2.html
  3. +12 −0 test/unit/dom-bind-elements1.html
  4. +7 −0 test/unit/dom-bind.html
View
9 src/standard/configure.html
@@ -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 = [];
},
@@ -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') {
View
68 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>
View
12 test/unit/dom-bind-elements1.html
@@ -7,4 +7,16 @@
}
}
});
+</script>
+
+<script>
+ Polymer({
+ is: 'x-produce-a',
+ properties: {
+ a: {
+ notify: true,
+ value: 'a'
+ }
+ }
+ });
</script>
View
7 test/unit/dom-bind.html
@@ -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">
@@ -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() {

0 comments on commit 1a5c391

Please sign in to comment.
Something went wrong with that request. Please try again.