Skip to content

Commit

Permalink
Fixes #92. Array behaviors now properly add to rather than replace ex…
Browse files Browse the repository at this point in the history
…isting behaviors.
  • Loading branch information
Steven Orvell committed Aug 25, 2016
1 parent 24881c4 commit 3945c7e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/compat/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
var b = behaviors[i];
if (b) {
if (Array.isArray(b)) {
r = flattenBehaviors(b);
r = r.concat(flattenBehaviors(b));
} else {
if (r.indexOf(b) < 0) {
r.push(b);
Expand Down
66 changes: 66 additions & 0 deletions test/smoke/behaviors-compose.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!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
-->
<html>
<head>
<title>Polymer - composed behaviors</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="../../polymer.html">

</head>
<body>
<script>
var SomeBehavior = [{
properties: {
some: {
type: Boolean,
value: true
}
}
}, {
properties: {
someExtended: {
type: Boolean,
value: true
}
}
}];

var OtherBehavior = [{
properties: {
other: {
type: Boolean,
value: true
}
}
}, {
properties: {
otherExtended: {
type: Boolean,
value: true
}
}
}];

Polymer({
is: 'x-sample',
behaviors: [SomeBehavior, OtherBehavior],
attached: function() {
console.log(this.some, this.someExtended, this.other, this.otherExtended);
}
});
</script>

<x-sample></x-sample>
</body>
</html>
2 changes: 1 addition & 1 deletion test/unit/behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@

behaviors: [
[[Polymer.BehaviorC, Polymer.BehaviorB], Polymer.BehaviorA],
Polymer.BehaviorD
[Polymer.BehaviorD]
]
});
</script>
Expand Down

0 comments on commit 3945c7e

Please sign in to comment.