Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: third_party/polymer/v0_8/components-chromium/more-routing/params-extracted.js

Issue 1155683008: Rename polymer and cr_elements v0_8 to v1_0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v1
Patch Set: fix a merge mistake Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1
2 (function(scope) {
3 var MoreRouting = scope.MoreRouting = scope.MoreRouting || {};
4 MoreRouting.Params = Params;
5
6 /**
7 * A collection of route parameters and their values, with nofications.
8 *
9 * Params prefixed by `__` are reserved.
10 *
11 * @param {!Array<string>} params The keys of the params being managed.
12 * @param {Params=} parent A parent route's params to inherit.
13 * @return {Params}
14 */
15 function Params(params, parent) {
16 var model = Object.create(parent || Params.prototype);
17 // We have a different set of listeners at every level of the hierarchy.
18 Object.defineProperty(model, '__listeners', {value: []});
19
20 // We keep all state enclosed within this closure so that inheritance stays
21 // relatively straightfoward.
22 var state = {};
23 _compile(model, params, state);
24
25 return model;
26 }
27 Params.prototype = Object.create(MoreRouting.Emitter);
28
29 // Utility
30
31 function _compile(model, params, state) {
32 params.forEach(function(param) {
33 Object.defineProperty(model, param, {
34 get: function() {
35 return state[param];
36 },
37 set: function(value) {
38 if (state[param] === value) return;
39 state[param] = value;
40 model.__notify(param, value);
41 },
42 });
43 });
44 }
45
46 })(window);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698