Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Matheus Faustino 2018-09-13 19:15:13 -03:00
commit 5a5262b1d2
No known key found for this signature in database
GPG Key ID: A132F02D41D2F4A6

View File

@ -304,7 +304,14 @@ function createStyleElement({
if (check) detectSloppyRegexps([style]);
const oldElement = $(ENTRY_ID_PREFIX + style.id);
if (oldElement) {
if (oldElement && oldElement.contains(document.activeElement)) {
// preserve the focused element inside
const {className} = document.activeElement;
oldElement.parentNode.replaceChild(entry, oldElement);
// we're not using $() since className may contain multiple tokens
const el = entry.getElementsByClassName(className)[0];
if (el) el.focus();
} else if (oldElement) {
oldElement.parentNode.replaceChild(entry, oldElement);
} else {
container.appendChild(entry);
@ -328,6 +335,8 @@ Object.assign(handleEvent, {
},
toggle(event) {
// when fired on checkbox, prevent the parent label from seeing the event, see #501
event.stopPropagation();
API.saveStyle({
id: handleEvent.getClickedStyleId(event),
enabled: this.matches('.enable') || this.checked,