Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/datepicker/js/calendarMonth.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// The <tr> ensures that the <tbody> will always have the
// proper height, even if it's empty. If it's content is
// compiled, the <tr> will be overwritten.
'<tr aria-hidden="true" style="height:' + TBODY_HEIGHT + 'px;"></tr>' +
'<tr aria-hidden="true" md-force-height="\'' + TBODY_HEIGHT + 'px\'"></tr>' +
'</tbody>' +
'</table>' +
'</md-virtual-repeat-container>' +
Expand Down
2 changes: 1 addition & 1 deletion src/components/datepicker/js/calendarYear.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'md-item-size="' + TBODY_HEIGHT + '">' +
// The <tr> ensures that the <tbody> will have the proper
// height, even though it may be empty.
'<tr aria-hidden="true" style="height:' + TBODY_HEIGHT + 'px;"></tr>' +
'<tr aria-hidden="true" md-force-height="\'' + TBODY_HEIGHT + 'px\'"></tr>' +
'</tbody>' +
'</table>' +
'</md-virtual-repeat-container>' +
Expand Down
32 changes: 31 additions & 1 deletion src/components/virtualRepeat/virtual-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ angular.module('material.components.virtualRepeat', [
'material.components.showHide'
])
.directive('mdVirtualRepeatContainer', VirtualRepeatContainerDirective)
.directive('mdVirtualRepeat', VirtualRepeatDirective);
.directive('mdVirtualRepeat', VirtualRepeatDirective)
.directive('mdForceHeight', ForceHeightDirective);


/**
Expand Down Expand Up @@ -989,3 +990,32 @@ VirtualRepeatModelArrayLike.prototype.$$includeIndexes = function(start, end) {
}
this.length = this.model.getLength();
};

/**
* @ngdoc directive
* @name mdForceHeight
* @module material.components.virtualRepeat
* @restrict A
* @description
*
* Force an element to have a certain px height. This is used in place of a style tag in order to
* conform to the Content Security Policy regarding unsafe-inline style tags.
*
* @usage
* <hljs lang="html">
* <div md-force-height="'100px'"></div>
* </hljs>
*/
function ForceHeightDirective($mdUtil) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var height = scope.$eval(attrs.mdForceHeight) || null;

if (height && element) {
element[0].style.height = height;
}
}
}
}
ForceHeightDirective.$inject = ['$mdUtil'];