-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(menu-item): properly compile when used with ng-repeat #8852
Conversation
ae73459
to
756d583
Compare
setDefault('role', (templateAttrs.type == 'checkbox') ? 'menuitemcheckbox' : 'menuitemradio', buttonEl); | ||
angular.forEach(['ng-disabled'], moveAttrToButton); | ||
setDefault('role', type == 'checkbox' ? 'menuitemcheckbox' : 'menuitemradio', buttonEl); | ||
moveAttrToButton('ng-disabled'); |
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.
This function should be updated to use the prefixer
.
To check if the attribute (with all prefixes) is present on the element.
$mdUtil.prefixer().hasAttribute(element, 'ng-disabled');
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.
Done.
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.
Sorry I was not clear.
I mean, that we should also move prefixed attributes.
function moveAttrToButton(attribute) {
var attributes = $mdUtil.prefixer(attribute);
attributes.forEach(function(attr) {
if (templateEl.hasAttribute(attr) {
button[0].setAttribute(attr, val);
templateEl[0].removeAttribute(attr);
}
}
756d583
to
3206a22
Compare
@@ -20,10 +23,11 @@ function MenuItemDirective($mdUtil) { | |||
templateEl.html(''); | |||
templateEl.append(angular.element('<md-icon md-svg-icon="check"></md-icon>')); | |||
templateEl.append(buttonEl); | |||
templateEl[0].classList.add('md-indent'); | |||
templateEl.addClass('md-indent'); | |||
templateAttrs.$set('mdInMenuBar', null); |
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.
I think you forgot to change that - it should remove the class.
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.
Ops, thanks. Good catch.
8ec3fd5
to
1e15366
Compare
* Fixes the menuItem directive not compiling properly when used together with ngRepeat. This is due to the fact that ngRepeat passes around a documentFragment, instead of a DOM node, which means that it doesn't have a parent and doesn't allow us to properly determine whether the menuItem is inside of a menuBar. This change switches the behavior by making the menuBar directive mark it's children instead. * Minor cleanup in the menuItem directive. * Avoided some repetition in the menuBar unit tests. * Switches to using the prefixer in the menuItem directive. Referencing angular#8117. Fixes angular#8697.
1e15366
to
d0a51b5
Compare
@ThomasBurleson Looks good to me ;) |
Referencing #8117.
Fixes #8697.