Skip to content

Commit

Permalink
Fixes from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Oct 10, 2015
1 parent b1c1b35 commit a300862
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/lib/annotations/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@

_bindingRegex: /([^{[]*)({{|\[\[)([^}\]]*)(?:]]|}})/g,

// TODO(kschaaf): We could modify this to allow an escape mechanism by
// looking for the escape sequence in each of the matches and converting
// the part back to a literal type, and then bailing if only literals
// were found
_parseBindings: function(text) {
var re = this._bindingRegex;
var parts = [];
Expand All @@ -114,7 +118,7 @@
var negate = false;
if (value[0] == '!') {
negate = true;
value = value.substring(1);
value = value.substring(1).trim();
}
var customEvent, notifyEvent, colon;
if (mode == '{' && (colon = value.indexOf('::')) > 0) {
Expand Down Expand Up @@ -277,25 +281,25 @@
},

// construct annotation data from a generic attribute, or undefined
_parseNodeAttributeAnnotation: function(node, n, v) {
var parts = this._parseBindings(v);
_parseNodeAttributeAnnotation: function(node, name, value) {
var parts = this._parseBindings(value);
if (parts) {
// Attribute or property
var name = n;
var origName = name;
var kind = 'property';
if (n[n.length-1] == '$') {
name = n.slice(0, -1);
if (name[name.length-1] == '$') {
name = name.slice(0, -1);
kind = 'attribute';
}
// Clear attribute before removing, since IE won't allow removing
// `value` attribute if it previously had a value (can't
// unconditionally set '' before removing since attributes with `$`
// can't be set using setAttribute)
if (node.localName == 'input' && n == 'value') {
node.setAttribute(n, '');
if (node.localName == 'input' && name == 'value') {
node.setAttribute(origName, '');
}
// Remove annotation
node.removeAttribute(n);
node.removeAttribute(origName);
// Case hackery: attributes are lower-case, but bind targets
// (properties) are case sensitive. Gambit is to map dash-case to
// camel-case: `foo-bar` becomes `fooBar`.
Expand Down
1 change: 1 addition & 0 deletions src/lib/bind/effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
_shouldAddListener: function(effect) {
return effect.name &&
effect.kind != 'attribute' &&
effect.kind != 'text' &&
!effect.isCompound &&
effect.parts[0].mode === '{' &&
!effect.parts[0].negate;
Expand Down

0 comments on commit a300862

Please sign in to comment.