Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace most remaining Element.setAttribute("style", ...) usage with Element.style = ... instead #11569

Merged
merged 1 commit into from Feb 8, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/display/font_loader.js
Expand Up @@ -341,12 +341,11 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
names.push(loadTestFontId);

const div = document.createElement("div");
div.setAttribute(
"style",
"visibility: hidden;" +
"width: 10px; height: 10px;" +
"position: absolute; top: 0px; left: 0px;"
);
div.style.visibility = "hidden";
div.style.width = div.style.height = "10px";
div.style.position = "absolute";
div.style.top = div.style.left = "0px";

for (i = 0, ii = names.length; i < ii; ++i) {
const span = document.createElement("span");
span.textContent = "Hi";
Expand Down
6 changes: 1 addition & 5 deletions web/debugger.js
Expand Up @@ -67,7 +67,6 @@ var FontInspector = (function FontInspectorClosure() {
manager: null,
init: function init(pdfjsLib) {
var panel = this.panel;
panel.setAttribute("style", "padding: 5px;");
var tmp = document.createElement("button");
tmp.addEventListener("click", resetSelection);
tmp.textContent = "Refresh";
Expand Down Expand Up @@ -178,7 +177,6 @@ var StepperManager = (function StepperManagerClosure() {
manager: null,
init: function init(pdfjsLib) {
var self = this;
this.panel.setAttribute("style", "padding: 5px;");
stepperControls = document.createElement("div");
stepperChooser = document.createElement("select");
stepperChooser.addEventListener("change", function(event) {
Expand Down Expand Up @@ -468,9 +466,7 @@ var Stats = (function Stats() {
name: "Stats",
panel: null,
manager: null,
init(pdfjsLib) {
this.panel.setAttribute("style", "padding: 5px;");
},
init(pdfjsLib) {},
enabled: false,
active: false,
// Stats specific functions.
Expand Down
9 changes: 2 additions & 7 deletions web/pdf_outline_viewer.js
Expand Up @@ -94,16 +94,11 @@ class PDFOutlineViewer {
* @private
*/
_setStyles(element, { bold, italic }) {
let styleStr = "";
if (bold) {
styleStr += "font-weight: bold;";
element.style.fontWeight = "bold";
}
if (italic) {
styleStr += "font-style: italic;";
}

if (styleStr) {
element.setAttribute("style", styleStr);
element.style.fontStyle = "italic";
}
}

Expand Down
6 changes: 2 additions & 4 deletions web/secondary_toolbar.js
Expand Up @@ -340,10 +340,8 @@ class SecondaryToolbar {
if (this.containerHeight === this.previousContainerHeight) {
return;
}
this.toolbarButtonContainer.setAttribute(
"style",
"max-height: " + (this.containerHeight - SCROLLBAR_PADDING) + "px;"
);
this.toolbarButtonContainer.style.maxHeight = `${this.containerHeight -
SCROLLBAR_PADDING}px`;

this.previousContainerHeight = this.containerHeight;
}
Expand Down
5 changes: 1 addition & 4 deletions web/ui_utils.js
Expand Up @@ -890,10 +890,7 @@ class ProgressBar {
const container = viewer.parentNode;
const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
if (scrollbarWidth > 0) {
this.bar.setAttribute(
"style",
"width: calc(100% - " + scrollbarWidth + "px);"
);
this.bar.style.width = `calc(100% - ${scrollbarWidth}px)`;
}
}

Expand Down
3 changes: 3 additions & 0 deletions web/viewer.css
Expand Up @@ -1483,6 +1483,9 @@ html[dir='rtl'] #documentPropertiesOverlay .row > * {
right: 0;
top: 27px;
}
#PDFBug .panels > div {
padding: 5px;
}
#PDFBug button.active {
font-weight: bold;
}
Expand Down