mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Prevent style changes to wrapper divs (#2646)
Prevent style changes to wrapper divs
This commit is contained in:
parent
991bdb8c95
commit
5d6c4834fd
4 changed files with 22 additions and 0 deletions
|
|
@ -117,6 +117,7 @@ class Autocomplete {
|
|||
this.container.append(this.list);
|
||||
this.shadowRoot.append(this.container);
|
||||
document.body.append(this.wrapper);
|
||||
kpxcUI.observeWrapper(this.wrapper);
|
||||
|
||||
// Add a footer message for auto-submit
|
||||
if (this.autoSubmit) {
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ kpxcBanner.create = async function(credentials = {}) {
|
|||
|
||||
if (window.self === window.top && !kpxcBanner.created) {
|
||||
window.parent.document.body.appendChild(wrapper);
|
||||
kpxcUI.observeWrapper(wrapper);
|
||||
kpxcBanner.created = true;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ kpxcCustomLoginFieldsBanner.create = async function() {
|
|||
|
||||
if (!kpxcCustomLoginFieldsBanner.created) {
|
||||
window.self.document.body.appendChild(wrapper);
|
||||
kpxcUI.observeWrapper(wrapper);
|
||||
kpxcCustomLoginFieldsBanner.created = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ class Icon {
|
|||
this.shadowRoot.append(styleSheet);
|
||||
this.shadowRoot.append(this.icon);
|
||||
document.body.append(wrapper);
|
||||
kpxcUI.observeWrapper(wrapper);
|
||||
}
|
||||
|
||||
switchIcon(state, uuid) {
|
||||
|
|
@ -394,6 +395,22 @@ kpxcUI.createButton = function(color, textContent, callback) {
|
|||
return button;
|
||||
};
|
||||
|
||||
// Observe and prevent style changes to wrapper div elements
|
||||
kpxcUI.createWrapperObserver = function() {
|
||||
kpxcUI.wrapperObserver = new MutationObserver(function(mutations, obs) {
|
||||
for (const mut of mutations) {
|
||||
if (mut?.target && mut.target.style?.cssText !== 'all: unset;') {
|
||||
mut.target.removeAttribute('style');
|
||||
mut.target.style.all = 'unset';
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
kpxcUI.observeWrapper = function(elem) {
|
||||
kpxcUI.wrapperObserver.observe(elem, { attributes: true, attributeFilter: [ 'style' ] });
|
||||
};
|
||||
|
||||
const DOMRectToArray = function(domRect) {
|
||||
return [ domRect.bottom, domRect.height, domRect.left, domRect.right, domRect.top, domRect.width, domRect.x, domRect.y ];
|
||||
};
|
||||
|
|
@ -439,6 +456,8 @@ document.addEventListener('mouseup', function(e) {
|
|||
kpxcUI.mouseDown = false;
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', kpxcUI.createWrapperObserver());
|
||||
|
||||
HTMLDivElement.prototype.appendMultiple = function(...args) {
|
||||
for (const a of args) {
|
||||
this.append(a);
|
||||
|
|
|
|||
Loading…
Reference in a new issue