Skip to content

Commit

Permalink
fix: use 'insertAdjacentElement' instead of 'append' (#31)
Browse files Browse the repository at this point in the history
* fix: use 'insertAdjacentElement' instead of 'append'

* check 'window.indexedDB.databases'
  • Loading branch information
wqcstrong committed Jan 2, 2024
1 parent 68b8202 commit 3ea8651
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/component/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class Content {
e.stopPropagation();
if (onOk) onOk();
};
this.el.append(info, button);
this.el.insertAdjacentElement('beforeend', info);
this.el.insertAdjacentElement('beforeend', button);
}
}
4 changes: 2 additions & 2 deletions src/component/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Modal {
}, 300);
}

append(node: HTMLElement) {
this.el.appendChild(node);
appendNode(node: HTMLElement) {
this.el.insertAdjacentElement('beforeend', node);
}
}
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ export default class PageSpy {
img.src = logoUrl;
img.width = 50;
img.height = 50;
logo.append(img);
root.insertAdjacentElement('afterbegin', logo);
logo.insertAdjacentElement('beforeend', img);
root.insertAdjacentElement('beforeend', logo);
window.addEventListener('sdk-inactive', () => {
logo.classList.add('inactive');
});
Expand Down Expand Up @@ -256,8 +256,8 @@ export default class PageSpy {
modal.close();
},
});
modal.append(content.el!);
root.append(modal.el);
modal.appendNode(content.el!);
root.insertAdjacentElement('beforeend', modal.el);

function showModal(e: any) {
const { isMoveEvent } = logo as unknown as UElement;
Expand All @@ -270,7 +270,7 @@ export default class PageSpy {
}
logo.addEventListener('click', showModal, false);
logo.addEventListener('touchend', showModal, false);
document.documentElement.append(root);
document.documentElement.insertAdjacentElement('beforeend', root);
moveable(logo);
this.handleDeviceDPR();

Expand Down
9 changes: 8 additions & 1 deletion src/plugins/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ export class DatabasePlugin implements PageSpyPlugin {
public static hasInitd = false;

private static get isSupport() {
if (!IDBFactory || !IDBObjectStore || !window.indexedDB) return false;
if (
!IDBFactory ||
!IDBObjectStore ||
!window.indexedDB ||
!window.indexedDB.databases
) {
return false;
}
return true;
}

Expand Down

0 comments on commit 3ea8651

Please sign in to comment.