Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit e1345ae

Browse files
topherfangiokara
authored andcommitted
fix(calendar): conform to CSP. (#10519)
Fixes #10389.
1 parent 4e579dd commit e1345ae

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

src/components/datepicker/js/calendarMonth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// The <tr> ensures that the <tbody> will always have the
3838
// proper height, even if it's empty. If it's content is
3939
// compiled, the <tr> will be overwritten.
40-
'<tr aria-hidden="true" style="height:' + TBODY_HEIGHT + 'px;"></tr>' +
40+
'<tr aria-hidden="true" md-force-height="\'' + TBODY_HEIGHT + 'px\'"></tr>' +
4141
'</tbody>' +
4242
'</table>' +
4343
'</md-virtual-repeat-container>' +

src/components/datepicker/js/calendarYear.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
'md-item-size="' + TBODY_HEIGHT + '">' +
2727
// The <tr> ensures that the <tbody> will have the proper
2828
// height, even though it may be empty.
29-
'<tr aria-hidden="true" style="height:' + TBODY_HEIGHT + 'px;"></tr>' +
29+
'<tr aria-hidden="true" md-force-height="\'' + TBODY_HEIGHT + 'px\'"></tr>' +
3030
'</tbody>' +
3131
'</table>' +
3232
'</md-virtual-repeat-container>' +

src/components/virtualRepeat/virtual-repeater.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ angular.module('material.components.virtualRepeat', [
77
'material.components.showHide'
88
])
99
.directive('mdVirtualRepeatContainer', VirtualRepeatContainerDirective)
10-
.directive('mdVirtualRepeat', VirtualRepeatDirective);
10+
.directive('mdVirtualRepeat', VirtualRepeatDirective)
11+
.directive('mdForceHeight', ForceHeightDirective);
1112

1213

1314
/**
@@ -989,3 +990,32 @@ VirtualRepeatModelArrayLike.prototype.$$includeIndexes = function(start, end) {
989990
}
990991
this.length = this.model.getLength();
991992
};
993+
994+
/**
995+
* @ngdoc directive
996+
* @name mdForceHeight
997+
* @module material.components.virtualRepeat
998+
* @restrict A
999+
* @description
1000+
*
1001+
* Force an element to have a certain px height. This is used in place of a style tag in order to
1002+
* conform to the Content Security Policy regarding unsafe-inline style tags.
1003+
*
1004+
* @usage
1005+
* <hljs lang="html">
1006+
* <div md-force-height="'100px'"></div>
1007+
* </hljs>
1008+
*/
1009+
function ForceHeightDirective($mdUtil) {
1010+
return {
1011+
restrict: 'A',
1012+
link: function(scope, element, attrs) {
1013+
var height = scope.$eval(attrs.mdForceHeight) || null;
1014+
1015+
if (height && element) {
1016+
element[0].style.height = height;
1017+
}
1018+
}
1019+
}
1020+
}
1021+
ForceHeightDirective.$inject = ['$mdUtil'];

0 commit comments

Comments
 (0)