Skip to content

Commit

Permalink
fix: dont use this
Browse files Browse the repository at this point in the history
  • Loading branch information
maxakuru committed Sep 18, 2024
1 parent fc9c172 commit 21b2b7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
7 changes: 4 additions & 3 deletions tools/oversight/elements/url-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class URLSelector extends HTMLElement {

async connectedCallback() {
this.innerHTML = this.template;
const datalist = this.querySelector('datalist');
const input = this.querySelector('input');
input.value = new URL(window.location.href).searchParams.get('domain');
const img = this.querySelector('img');
Expand All @@ -43,7 +44,7 @@ export default class URLSelector extends HTMLElement {
const token = getPersistentToken();
if (!token) {
input.disabled = true;
this.datalist.remove();
datalist.remove();

// detect a click with shift key pressed
img.addEventListener('click', (event) => {
Expand All @@ -62,13 +63,13 @@ export default class URLSelector extends HTMLElement {
},
});
if (!resp.ok) {
this.datalist.remove();
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
this.datalist.appendChild(option);
datalist.appendChild(option);
});
}
}
Expand Down
11 changes: 4 additions & 7 deletions tools/rum/elements/url-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ function getPersistentToken() {
}

export default class URLSelector extends HTMLElement {
/** @type {HTMLDataListElement} */
datalist = null;

constructor() {
super();
this.template = `
Expand Down Expand Up @@ -38,7 +35,7 @@ export default class URLSelector extends HTMLElement {

async connectedCallback() {
this.innerHTML = this.template;
this.datalist = this.querySelector('datalist');
const datalist = this.querySelector('datalist');
const input = this.querySelector('input');
input.value = new URL(window.location.href).searchParams.get('domain');
const img = this.querySelector('img');
Expand All @@ -47,7 +44,7 @@ export default class URLSelector extends HTMLElement {
const token = getPersistentToken();
if (!token) {
input.disabled = true;
this.datalist.remove();
datalist.remove();
} else {
const resp = await fetch('https://rum.fastly-aem.page/domains?suggested=true', {
headers: {
Expand All @@ -56,13 +53,13 @@ export default class URLSelector extends HTMLElement {
},
});
if (!resp.ok) {
this.datalist.remove();
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
this.datalist.appendChild(option);
datalist.appendChild(option);
});
}
}
Expand Down

0 comments on commit 21b2b7b

Please sign in to comment.