Skip to content

Commit fdce677

Browse files
Merge pull request #52 from tommcc/fix-sg-raw-checks
Fix JS errors when "Open in new window" menu is hidden
2 parents fcf3160 + 1819b15 commit fdce677

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/js/styleguide.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@
517517
history.replaceState({ "pattern": patternName }, null, null);
518518
}
519519

520-
if (document.getElementById("sg-raw") !== undefined) {
520+
if (document.getElementById("sg-raw") !== null) {
521521
document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(patternName));
522522
}
523523

src/js/url-handler.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ var urlHandler = {
153153
history.pushState(data, null, addressReplacement);
154154
}
155155
document.getElementById("title").innerHTML = "Pattern Lab - "+pattern;
156-
if (document.getElementById("sg-raw") !== undefined) {
156+
if (document.getElementById("sg-raw") !== null) {
157157
document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(pattern));
158158
}
159159
}
@@ -184,7 +184,9 @@ var urlHandler = {
184184
var obj = JSON.stringify({ "event": "patternLab.updatePath", "path": iFramePath });
185185
document.getElementById("sg-viewport").contentWindow.postMessage( obj, urlHandler.targetOrigin);
186186
document.getElementById("title").innerHTML = "Pattern Lab - "+patternName;
187-
document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(patternName));
187+
if (document.getElementById("sg-raw") !== null) {
188+
document.getElementById("sg-raw").setAttribute("href",urlHandler.getFileName(patternName));
189+
}
188190

189191
/*
190192
if (wsnConnected !== undefined) {

0 commit comments

Comments
 (0)