Make fire2 fire. Remove keyPresses. Remove comments.

This commit is contained in:
Kevin Schaaf
2015-04-21 18:29:57 -07:00
parent b9571246b4
commit 5e05fd709e
14 changed files with 22 additions and 102 deletions

View File

@@ -22,8 +22,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_registerFeatures: function() {
// identity
this._prepIs();
// shared methods
//this._prepMixins();
// shared behaviors
this._prepBehaviors();
// inheritance
@@ -37,7 +35,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_initFeatures: function() {
// acquire behaviors
this._marshalBehaviors();
//this._marshalAttributes();
},
_marshalBehavior: function(b) {

View File

@@ -26,7 +26,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this._prepIs();
// shared behaviors
this._prepBehaviors();
//this._prepMixins();
// inheritance
this._prepExtends();
// factory

View File

@@ -27,10 +27,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_registerFeatures: function() {
// identity
this._prepIs();
// shared methods
//this._prepMixins();
// shared behaviors
//this._prepBehaviors();
// inheritance
this._prepExtends();
// factory
@@ -82,7 +78,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this._installHostAttributes(b.hostAttributes);
// establish listeners on instance
this._listenListeners(b.listeners);
this._listenKeyPresses(b.keyPresses);
}
});

View File

@@ -30,7 +30,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// TODO(sjmiles): oops, `fire` doesn't exist at this layer
this.fire(eventName, {
value: this[property]
}, null, false);
}, {bubbles: false});
},
// TODO(sjmiles): removing _notifyListener from here breaks accessors.html
@@ -95,7 +95,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
fx.push({
kind: kind,
effect: effect
});
});
},
createBindings: function(model) {

View File

@@ -59,7 +59,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_marshalAttributes: function() {
this._takeAttributes();
//this._installHostAttributes(this.hostAttributes);
},
_installHostAttributes: function(attributes) {

View File

@@ -69,7 +69,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Object.getOwnPropertyNames(b).forEach(function(n) {
switch (n) {
case 'registered':
case 'accessors':
case 'observers':
case 'listeners':
case 'keyPresses':
case 'hostAttributes':

View File

@@ -61,15 +61,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
properties: {
},
/*getPropertyInfo: function(property) {
return this._getPropertyInfo(property, this.properties);
},*/
getPropertyInfo: function(property) {
var info = this._getPropertyInfo(property, this.properties);
if (!info) {
this.behaviors.some(function(b) {
return info = this._getPropertyInfo(property, b.accessors);
return info = this._getPropertyInfo(property, b.properties);
}, this);
}
return info || Polymer.nob;

View File

@@ -73,7 +73,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this._configureProperties(this.properties, config);
// behave!
this.behaviors.forEach(function(b) {
this._configureProperties(b.accessors, config);
this._configureProperties(b.properties, config);
}, this);
// get add'l default values from central configure
// combine defaults returned from configure with inputs in _config

View File

@@ -45,13 +45,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
listeners: {},
_marshalListeners: function() {
/*
this._listenListeners(this.listeners);
this._listenKeyPresses(this.keyPresses);
*/
},
_listenListeners: function(listeners) {
var node, name, key;
for (key in listeners) {
@@ -87,53 +80,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
node.addEventListener(eventName, handler);
break;
}
},
keyPresses: {},
_listenKeyPresses: function(keyPresses) {
// for..in here to gate empty keyPresses object (iterates once or never)
for (var n in keyPresses) {
// only get here if there is something in keyPresses
// TODO(sjmiles): _keyPressesFeatureHandler uses `this.keyPresses`
// to look up keycodes, it's not agnostic like this method is
this.addEventListener('keydown', this._keyPressesFeatureHandler);
// map string keys to numeric codes
for (n in keyPresses) {
if (typeof n === 'string') {
keyPresses[this.eventKeyCodes[n]] = keyPresses[n];
}
}
break;
}
},
_keyPressesFeatureHandler: function(e) {
var method = this.keyPresses[e.keyCode];
if (method && this[method]) {
return this[method](e.keyCode, e);
}
},
// bc
eventKeyCodes: {
ESC_KEY: 27,
ENTER_KEY: 13,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
SPACE: 32
},
keyCodes: {
ESC_KEY: 27,
ENTER_KEY: 13,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
SPACE: 32
}
});

View File

@@ -183,7 +183,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_pathMatchesEffect: function(path, effect) {
var effectArg = effect.arg.name;
return (effectArg == path) ||
return (effectArg == path) ||
(effectArg.indexOf(path + '.') === 0) ||
(effect.arg.wildcard && path.indexOf(effectArg) === 0);
},
@@ -237,7 +237,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this.fire(eventName, {
path: path,
value: value
}, null, false);
}, {bubbles: false});
},
_modelForPath: function(path) {

View File

@@ -64,25 +64,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
});
},
// TODO(sjmiles): use a dictionary for options after `detail`
fire: function(type, detail, onNode, bubbles, cancelable) {
var node = onNode || this;
var detail = (detail === null || detail === undefined) ? {} : detail;
var event = new CustomEvent(type, {
bubbles: bubbles !== undefined ? bubbles : true,
cancelable: cancelable !== undefined ? cancelable : true,
detail: detail
});
node.dispatchEvent(event);
return event;
},
fire2: function(type, detail, options) {
var node = onNode || this;
var detail = (detail === null || detail === undefined) ? Polymer.nob : detail;
fire: function(type, detail, options) {
options = options || Polymer.nob;
var node = options.node || this;
var detail = (detail === null || detail === undefined) ? Polymer.nob : detail;
var bubbles = options.bubbles === undefined ? true : options.bubbles;
var event = new CustomEvent(type, {
bubbles: Boolean(options.bubbles),
bubbles: Boolean(bubbles),
cancelable: Boolean(options.cancelable),
detail: detail
});

View File

@@ -12,7 +12,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.BehaviorA = {
accessors: {
properties: {
label: {
type: String,
@@ -45,7 +45,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.BehaviorB = {
accessors: {
properties: {
disabled: {
type: Boolean,

View File

@@ -156,7 +156,7 @@ suite('single-element binding effects', function() {
el.divide = 3;
assert.equal(el.$.boundChild.computedInline, 20, 'computedInline not correct');
assert.equal(el.$.boundChild.computedInline2, 20, 'computedInline2 not correct');
});
});
test('annotated computed attribute', function() {
el.value = 20;
@@ -178,14 +178,14 @@ suite('single-element binding effects', function() {
test('custom notification event to property', function() {
el.$.boundChild.customEventValue = 42;
el.fire('custom', null, el.$.boundChild);
el.fire('custom', null, {node: el.$.boundChild});
assert.equal(el.customEventValue, 42, 'custom bound property incorrect');
assert.equal(el.observerCounts.customEventValueChanged, 1, 'custom bound property observer not called');
});
test('custom notification event to path', function() {
el.$.boundChild.customEventObjectValue = 84;
el.fire('change', null, el.$.boundChild);
el.fire('change', null, {node: el.$.boundChild});
assert.equal(el.customEventObject.value, 84, 'custom bound path incorrect');
assert.equal(el.observerCounts.customEventObjectValueChanged, 1, 'custom bound path observer not called');
});
@@ -410,7 +410,7 @@ suite('reflection to attribute', function() {
var date = new Date('Fri Jan 23 2015 17:40:29 GMT-0800 (PST)');
el.reflecteddate = date;
assert(el.hasAttribute('reflecteddate'));
assert.equal(Date.parse(el.getAttribute('reflecteddate')),
assert.equal(Date.parse(el.getAttribute('reflecteddate')),
el.reflecteddate.getTime());
assert.equal(el.reflecteddate, date);
el.reflecteddate = null;
@@ -490,7 +490,7 @@ suite('binding to attribute', function() {
test('bind date to attribute', function() {
el.attrvalue = new Date('Fri Jan 23 2015 17:40:29 GMT-0800 (PST)');
assert(el.$.boundChild.hasAttribute('attrvalue'));
assert.equal(Date.parse(el.$.boundChild.getAttribute('attrvalue')),
assert.equal(Date.parse(el.$.boundChild.getAttribute('attrvalue')),
el.attrvalue.getTime());
el.attrvalue = null;
assert(!el.$.boundChild.hasAttribute('attrvalue'));

View File

@@ -172,7 +172,7 @@ suite('Polymer.dom', function() {
var childCount = 5;
for (var i=0; i < childCount; i++) {
var s = document.createElement('span');
s.textContent = i;
s.textContent = i;
fragment.appendChild(s);
}
Polymer.dom(rere.root).appendChild(fragment);
@@ -191,7 +191,7 @@ suite('Polymer.dom', function() {
var childCount = 5;
for (var i=0; i < childCount; i++) {
var s = document.createElement('span');
s.textContent = i;
s.textContent = i;
fragment.appendChild(s);
}
var l = document.createElement('span');
@@ -300,7 +300,7 @@ suite('Polymer.dom', function() {
});
suite('Polymer.dom non-distributed elements', function() {
var nd;
before(function() {