Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Preventing DOM operations on null nodes (#166)
Browse files Browse the repository at this point in the history
* Adding reset styles to prevent stray styles

* Preventing DOM operations on null nodes

* Accidental commit
  • Loading branch information
davidkpiano authored Jul 7, 2017
1 parent 589e467 commit 4436bbd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ function postRender(initPromise) {
var expandButton = document.querySelector('#js-glimpse-expand-button');
var collapseButton = document.querySelector('#js-glimpse-collapse-button');

if (!hudData) {
// element does not exist yet
return;
}

ajaxView.postRender(initPromise);
logsView.postRender(initPromise);

Expand Down
5 changes: 5 additions & 0 deletions src/views/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ function update(request) {
}
function updateCounter(details, count) {
var counter = document.getElementById(details.countId);
if (!counter) {
// element does not exist yet
return;
}

counter.innerText = count;
dom.addClass(counter, 'glimpse-section-value--update');
if (details.timeout) {
Expand Down
10 changes: 10 additions & 0 deletions src/views/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ function update(model) {
function updateValue(target, summary) {
const element = document.getElementById(target);

if (!element) {
// element does not exist yet
return;
}

let content = summary.total;
if (summary.total > 0) {
dom.addClass(element, 'glimpse-time-ms');
Expand Down Expand Up @@ -96,6 +101,11 @@ function updateCoreListing(target, data, supportedRecords, isStatusCode) {
}

const targetElement = document.getElementById(target);
if (!targetElement) {
// element does not exist yet
return;
}

if (content.length > 0) {
targetElement.innerHTML = `${content}<div></div>`;
}
Expand Down

0 comments on commit 4436bbd

Please sign in to comment.