This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Scott J. Miles
committed
Mar 24, 2014
1 parent
4b38cdf
commit d38e028
Showing
1 changed file
with
88 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,88 @@ | ||
/* | ||
* Copyright 2013 The Polymer Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
(function(scope) { | ||
|
||
// element api | ||
|
||
var properties = { | ||
inferObservers: function(prototype) { | ||
// called before prototype.observe is chained to inherited object | ||
var observe = prototype.observe, property; | ||
for (var n in prototype) { | ||
if (n.slice(-7) === 'Changed') { | ||
if (!observe) { | ||
observe = (prototype.observe = {}); | ||
} | ||
property = n.slice(0, -7) | ||
observe[property] = observe[property] || n; | ||
} | ||
} | ||
}, | ||
explodeObservers: function(prototype) { | ||
// called before prototype.observe is chained to inherited object | ||
var o = prototype.observe; | ||
if (o) { | ||
var exploded = {}; | ||
for (var n in o) { | ||
var names = n.split(' '); | ||
for (var i=0, ni; ni=names[i]; i++) { | ||
exploded[ni] = o[n]; | ||
} | ||
} | ||
prototype.observe = exploded; | ||
} | ||
}, | ||
optimizePropertyMaps: function(prototype) { | ||
if (prototype.observe) { | ||
// construct name list | ||
var a = prototype._observeNames = []; | ||
for (var n in prototype.observe) { | ||
var names = n.split(' '); | ||
for (var i=0, ni; ni=names[i]; i++) { | ||
a.push(ni); | ||
} | ||
//a.push(n); | ||
} | ||
} | ||
if (prototype.publish) { | ||
// construct name list | ||
var a = prototype._publishNames = []; | ||
for (var n in prototype.publish) { | ||
a.push(n); | ||
} | ||
} | ||
}, | ||
publishProperties: function(prototype, base) { | ||
// if we have any properties to publish | ||
var publish = prototype.publish; | ||
if (publish) { | ||
// transcribe `publish` entries onto own prototype | ||
this.requireProperties(publish, prototype, base); | ||
// construct map of lower-cased property names | ||
prototype._publishLC = this.lowerCaseMap(publish); | ||
} | ||
}, | ||
requireProperties: function(properties, prototype, base) { | ||
// ensure a prototype value for each property | ||
for (var n in properties) { | ||
if (prototype[n] === undefined && base[n] === undefined) { | ||
prototype[n] = properties[n]; | ||
} | ||
} | ||
}, | ||
lowerCaseMap: function(properties) { | ||
var map = {}; | ||
for (var n in properties) { | ||
map[n.toLowerCase()] = n; | ||
} | ||
return map; | ||
} | ||
}; | ||
|
||
// exports | ||
|
||
scope.api.declaration.properties = properties; | ||
|
||
})(Polymer); | ||
/* | ||
* Copyright 2013 The Polymer Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
(function(scope) { | ||
|
||
// element api | ||
|
||
var properties = { | ||
inferObservers: function(prototype) { | ||
// called before prototype.observe is chained to inherited object | ||
var observe = prototype.observe, property; | ||
for (var n in prototype) { | ||
if (n.slice(-7) === 'Changed') { | ||
if (!observe) { | ||
observe = (prototype.observe = {}); | ||
} | ||
property = n.slice(0, -7) | ||
observe[property] = observe[property] || n; | ||
} | ||
} | ||
}, | ||
explodeObservers: function(prototype) { | ||
// called before prototype.observe is chained to inherited object | ||
var o = prototype.observe; | ||
if (o) { | ||
var exploded = {}; | ||
for (var n in o) { | ||
var names = n.split(' '); | ||
for (var i=0, ni; ni=names[i]; i++) { | ||
exploded[ni] = o[n]; | ||
} | ||
} | ||
prototype.observe = exploded; | ||
} | ||
}, | ||
optimizePropertyMaps: function(prototype) { | ||
if (prototype.observe) { | ||
// construct name list | ||
var a = prototype._observeNames = []; | ||
for (var n in prototype.observe) { | ||
var names = n.split(' '); | ||
for (var i=0, ni; ni=names[i]; i++) { | ||
a.push(ni); | ||
} | ||
} | ||
} | ||
if (prototype.publish) { | ||
// construct name list | ||
var a = prototype._publishNames = []; | ||
for (var n in prototype.publish) { | ||
a.push(n); | ||
} | ||
} | ||
}, | ||
publishProperties: function(prototype, base) { | ||
// if we have any properties to publish | ||
var publish = prototype.publish; | ||
if (publish) { | ||
// transcribe `publish` entries onto own prototype | ||
this.requireProperties(publish, prototype, base); | ||
// construct map of lower-cased property names | ||
prototype._publishLC = this.lowerCaseMap(publish); | ||
} | ||
}, | ||
requireProperties: function(properties, prototype, base) { | ||
// ensure a prototype value for each property | ||
for (var n in properties) { | ||
if (prototype[n] === undefined && base[n] === undefined) { | ||
prototype[n] = properties[n]; | ||
} | ||
} | ||
}, | ||
lowerCaseMap: function(properties) { | ||
var map = {}; | ||
for (var n in properties) { | ||
map[n.toLowerCase()] = n; | ||
} | ||
return map; | ||
} | ||
}; | ||
|
||
// exports | ||
|
||
scope.api.declaration.properties = properties; | ||
|
||
})(Polymer); |