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

Commit 976f557

Browse files
Frank3Ktinayuangao
authored andcommitted
fix(panel): use class instead of style attribute (#10321)
Using a style attribute is prohibited when using strict CSP rules. Fixes #10085.
1 parent e06284a commit 976f557

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/components/panel/panel.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ MdPanelService.prototype._wrapTemplate = function(origTemplate) {
13091309
// height and width for positioning.
13101310
return '' +
13111311
'<div class="md-panel-outer-wrapper">' +
1312-
' <div class="md-panel" style="left: -9999px;">' + template + '</div>' +
1312+
' <div class="md-panel _md-panel-offscreen">' + template + '</div>' +
13131313
'</div>';
13141314
};
13151315

@@ -1325,7 +1325,7 @@ MdPanelService.prototype._wrapTemplate = function(origTemplate) {
13251325
MdPanelService.prototype._wrapContentElement = function(contentElement) {
13261326
var wrapper = angular.element('<div class="md-panel-outer-wrapper">');
13271327

1328-
contentElement.addClass('md-panel').css('left', '-9999px');
1328+
contentElement.addClass('md-panel _md-panel-offscreen');
13291329
wrapper.append(contentElement);
13301330

13311331
return wrapper;
@@ -1918,8 +1918,8 @@ MdPanelRef.prototype._addStyles = function() {
19181918
// Theme the element and container.
19191919
self._setTheming();
19201920

1921-
// Remove left: -9999px and add hidden class.
1922-
self.panelEl.css('left', '');
1921+
// Remove offscreen class and add hidden class.
1922+
self.panelEl.removeClass('_md-panel-offscreen');
19231923
self.panelContainer.addClass(MD_PANEL_HIDDEN);
19241924

19251925
resolve(self);

src/components/panel/panel.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
display: none;
1111
}
1212

13+
._md-panel-offscreen {
14+
left: -9999px;
15+
}
16+
1317
._md-panel-fullscreen {
1418
border-radius: 0;
1519
left: 0;

0 commit comments

Comments
 (0)