-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: [#1332] Return URL relative to window location in HTMLIFrameElem…
…ent.src
- Loading branch information
1 parent
614bd9d
commit aa67746
Showing
22 changed files
with
303 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 33 additions & 1 deletion
34
packages/happy-dom/src/nodes/html-details-element/HTMLDetailsElement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
import Event from '../../event/Event.js'; | ||
import HTMLElement from '../html-element/HTMLElement.js'; | ||
import * as PropertySymbol from '../../PropertySymbol.js'; | ||
import NamedNodeMap from '../../named-node-map/NamedNodeMap.js'; | ||
import HTMLDetailsElementNamedNodeMap from './HTMLDetailsElementNamedNodeMap.js'; | ||
|
||
/** | ||
* HTMLDetailsElement | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDetailsElement | ||
*/ | ||
export default class HTMLDetailsElement extends HTMLElement {} | ||
export default class HTMLDetailsElement extends HTMLElement { | ||
public override [PropertySymbol.attributes]: NamedNodeMap = new HTMLDetailsElementNamedNodeMap( | ||
this | ||
); | ||
|
||
// Events | ||
public ontoggle: (event: Event) => void | null = null; | ||
|
||
/** | ||
* Returns the open attribute. | ||
*/ | ||
public get open(): boolean { | ||
return this.getAttribute('open') !== null; | ||
} | ||
|
||
/** | ||
* Sets the open attribute. | ||
* | ||
* @param open New value. | ||
*/ | ||
public set open(open: boolean) { | ||
if (open) { | ||
this.setAttribute('open', ''); | ||
} else { | ||
this.removeAttribute('open'); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/happy-dom/src/nodes/html-details-element/HTMLDetailsElementNamedNodeMap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Attr from '../attr/Attr.js'; | ||
import * as PropertySymbol from '../../PropertySymbol.js'; | ||
import HTMLElementNamedNodeMap from '../html-element/HTMLElementNamedNodeMap.js'; | ||
import Event from '../../event/Event.js'; | ||
import HTMLDetailsElement from './HTMLDetailsElement.js'; | ||
|
||
/** | ||
* Named Node Map. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap | ||
*/ | ||
export default class HTMLDetailsElementNamedNodeMap extends HTMLElementNamedNodeMap { | ||
protected [PropertySymbol.ownerElement]: HTMLDetailsElement; | ||
|
||
/** | ||
* @override | ||
*/ | ||
public override [PropertySymbol.setNamedItem](item: Attr): Attr | null { | ||
const replacedItem = super[PropertySymbol.setNamedItem](item); | ||
|
||
if (item[PropertySymbol.name] === 'open') { | ||
if (item[PropertySymbol.value] !== replacedItem?.[PropertySymbol.value]) { | ||
this[PropertySymbol.ownerElement].dispatchEvent(new Event('toggle')); | ||
} | ||
} | ||
|
||
return replacedItem || null; | ||
} | ||
|
||
/** | ||
* @override | ||
*/ | ||
public override [PropertySymbol.removeNamedItem](name: string): Attr | null { | ||
const removedItem = super[PropertySymbol.removeNamedItem](name); | ||
|
||
if (removedItem && removedItem[PropertySymbol.name] === 'open') { | ||
this[PropertySymbol.ownerElement].dispatchEvent(new Event('toggle')); | ||
} | ||
|
||
return removedItem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 84 additions & 1 deletion
85
packages/happy-dom/src/nodes/html-embed-element/HTMLEmbedElement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,90 @@ | ||
import HTMLElement from '../html-element/HTMLElement.js'; | ||
import * as PropertySymbol from '../../PropertySymbol.js'; | ||
|
||
/** | ||
* HTMLEmbedElement | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLEmbedElement | ||
*/ | ||
export default class HTMLEmbedElement extends HTMLElement {} | ||
export default class HTMLEmbedElement extends HTMLElement { | ||
/** | ||
* Returns height. | ||
* | ||
* @returns Height. | ||
*/ | ||
public get height(): string { | ||
return this.getAttribute('height') || ''; | ||
} | ||
|
||
/** | ||
* Sets height. | ||
* | ||
* @param height Height. | ||
*/ | ||
public set height(height: string) { | ||
this.setAttribute('height', height); | ||
} | ||
|
||
/** | ||
* Returns width. | ||
* | ||
* @returns Width. | ||
*/ | ||
public get width(): string { | ||
return this.getAttribute('width') || ''; | ||
} | ||
|
||
/** | ||
* Sets width. | ||
* | ||
* @param width Width. | ||
*/ | ||
public set width(width: string) { | ||
this.setAttribute('width', width); | ||
} | ||
|
||
/** | ||
* Returns source. | ||
* | ||
* @returns Source. | ||
*/ | ||
public get src(): string { | ||
if (!this.hasAttribute('src')) { | ||
return ''; | ||
} | ||
|
||
try { | ||
return new URL(this.getAttribute('src'), this[PropertySymbol.ownerDocument].location.href) | ||
.href; | ||
} catch (e) { | ||
return this.getAttribute('src'); | ||
} | ||
} | ||
|
||
/** | ||
* Sets source. | ||
* | ||
* @param src Source. | ||
*/ | ||
public set src(src: string) { | ||
this.setAttribute('src', src); | ||
} | ||
|
||
/** | ||
* Returns type. | ||
* | ||
* @returns Type. | ||
*/ | ||
public get type(): string { | ||
return this.getAttribute('type') || ''; | ||
} | ||
|
||
/** | ||
* Sets type. | ||
* | ||
* @param type Type. | ||
*/ | ||
public set type(type: string) { | ||
this.setAttribute('type', type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.