Skip to content

Commit

Permalink
Merge branch 'master' into 519-fixes-parse-conditional-comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mas0nShi committed Feb 23, 2023
2 parents 1e95e0a + 7f8ee01 commit 97e95e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
34 changes: 20 additions & 14 deletions packages/happy-dom/src/nodes/html-element/HTMLElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,18 @@ export default class HTMLElement extends Element implements IHTMLElement {

this.ownerDocument['_activeElement'] = null;

for (const eventType of ['blur', 'focusout']) {
const event = new FocusEvent(eventType, {
this.dispatchEvent(
new FocusEvent('blur', {
bubbles: false,
composed: true
})
);
this.dispatchEvent(
new FocusEvent('focusout', {
bubbles: true,
composed: true
});
event._target = this;
event._currentTarget = this;
this.dispatchEvent(event);
}
})
);
}

/**
Expand All @@ -408,15 +411,18 @@ export default class HTMLElement extends Element implements IHTMLElement {

this.ownerDocument['_activeElement'] = this;

for (const eventType of ['focus', 'focusin']) {
const event = new FocusEvent(eventType, {
this.dispatchEvent(
new FocusEvent('focus', {
bubbles: false,
composed: true
})
);
this.dispatchEvent(
new FocusEvent('focusin', {
bubbles: true,
composed: true
});
event._target = this;
event._currentTarget = this;
this.dispatchEvent(event);
}
})
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ describe('HTMLElement', () => {
element.blur();

expect(triggeredBlurEvent.type).toBe('blur');
expect(triggeredBlurEvent.bubbles).toBe(true);
expect(triggeredBlurEvent.bubbles).toBe(false);
expect(triggeredBlurEvent.composed).toBe(true);
expect(triggeredBlurEvent.target === element).toBe(true);

Expand Down Expand Up @@ -446,7 +446,7 @@ describe('HTMLElement', () => {
element.focus();

expect(triggeredFocusEvent.type).toBe('focus');
expect(triggeredFocusEvent.bubbles).toBe(true);
expect(triggeredFocusEvent.bubbles).toBe(false);
expect(triggeredFocusEvent.composed).toBe(true);
expect(triggeredFocusEvent.target === element).toBe(true);

Expand Down Expand Up @@ -502,7 +502,7 @@ describe('HTMLElement', () => {
element.focus();

expect(triggeredEvent.type).toBe('blur');
expect(triggeredEvent.bubbles).toBe(true);
expect(triggeredEvent.bubbles).toBe(false);
expect(triggeredEvent.composed).toBe(true);
expect(triggeredEvent.target === previousElement).toBe(true);
});
Expand Down

0 comments on commit 97e95e9

Please sign in to comment.