-
Notifications
You must be signed in to change notification settings - Fork 248
feat(NodeAttrs): Node attributes don't get initialized by NodeAttrs when #1001
feat(NodeAttrs): Node attributes don't get initialized by NodeAttrs when #1001
Conversation
@@ -57,7 +57,9 @@ class NodeAttrs { | |||
if (_mustacheAttrs[attrName].isComputed) notifyFn(this[attrName]); | |||
_mustacheAttrs[attrName].notifyFn(true); | |||
} else { | |||
notifyFn(this[attrName]); | |||
if(element.attributes.keys.contains(attrName) || element.attributes.keys.contains('ng-$attrName') || attrName == 'name') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we special casing ng-
??? Does not seem right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.keys.contains()
-> .containsKey()
@mhevery What do you think about "boolean attributes" (http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.4.2)? Should we initialise them all with true, instead of Actually, thinking more about this... I'm not sure if we can easily differentiate between |
@markovuksanovic This change is ready to be submitted, yes? |
@jbdeboer Yes, given the code is OK :) I just rebased it onto master. |
@@ -57,7 +57,10 @@ class NodeAttrs { | |||
if (_mustacheAttrs[attrName].isComputed) notifyFn(this[attrName]); | |||
_mustacheAttrs[attrName].notifyFn(true); | |||
} else { | |||
notifyFn(this[attrName]); | |||
if(element.attributes.keys.contains(attrName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
containsKey
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after if
setting up observing. In case an element does not have a value set for a propertyv, that property is not automatically initialised. For example: <div test foo="bar"> will cause ElementBinder to register observer (which will in turn cause initialisation) on property foo (of the directive) to bar, but if we try using <div test> foo property will not be initialised.
|
I'm hesitant about this PR. It is changing the component lifecycle but it unclear what problem it is solving. I'm not sure that ``null` is the correct choice for an undefined situation. In many cases, components want to set default values for properties and now can't distinguish between a null that was explicitly passed to the component and a null that actually means that the attribute was not defined. |
setting up observing. In case an element does not have a value set for a propertyv, that property is not automatically initialised. For example: <div test foo="bar"> will cause ElementBinder to register observer (which will in turn cause initialisation) on property foo (of the directive) to bar, but if we try using <div test> foo property will not be initialised. Closes #1001
@@ -57,7 +57,10 @@ class NodeAttrs { | |||
if (_mustacheAttrs[attrName].isComputed) notifyFn(this[attrName]); | |||
_mustacheAttrs[attrName].notifyFn(true); | |||
} else { | |||
notifyFn(this[attrName]); | |||
if (element.attributes.containsKey(attrName)) { | |||
var value = element.attributes[attrName]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable value
?
Closing, since this PR has perf implication. We really need to solve this in a unified way with bind-. |
setting up observing.
In case an element does not have an attribute set for a property defined
in NodeAttrs that property is not automatically initialised. Properties
that are initialised have to be set either using "name" or "ng-name"
attribute. For example:
will cause ElementBinder to register observer (which will in turn cause
initialisation) on property foo (of the directive) to bar, but if we try
using
foo property will not be initialised.