Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
16,547 additions
and
315 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
packages/happy-dom/src/nodes/html-input-element/HTMLInputElement.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
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
54 changes: 54 additions & 0 deletions
54
packages/happy-dom/src/nodes/html-opt-group-element/HTMLOptGroupElement.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,54 @@ | ||
import HTMLElement from '../html-element/HTMLElement'; | ||
import IHTMLOptGroupElement from './IHTMLOptGroupElement'; | ||
|
||
/** | ||
* HTML Opt Group Element. | ||
* | ||
* Reference: | ||
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptGroupElement. | ||
*/ | ||
export default class HTMLOptGroupElement extends HTMLElement implements IHTMLOptGroupElement { | ||
/** | ||
* Returns label. | ||
* | ||
* @returns Label. | ||
*/ | ||
public get label(): string { | ||
return this.getAttributeNS(null, 'label') || ''; | ||
} | ||
|
||
/** | ||
* Sets label. | ||
* | ||
* @param label Label. | ||
*/ | ||
public set label(label: string) { | ||
if (!label) { | ||
this.removeAttributeNS(null, 'label'); | ||
} else { | ||
this.setAttributeNS(null, 'label', label); | ||
} | ||
} | ||
|
||
/** | ||
* Returns disabled. | ||
* | ||
* @returns Disabled. | ||
*/ | ||
public get disabled(): boolean { | ||
return this.getAttributeNS(null, 'disabled') !== null; | ||
} | ||
|
||
/** | ||
* Sets disabled. | ||
* | ||
* @param disabled Disabled. | ||
*/ | ||
public set disabled(disabled: boolean) { | ||
if (!disabled) { | ||
this.removeAttributeNS(null, 'disabled'); | ||
} else { | ||
this.setAttributeNS(null, 'disabled', ''); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/happy-dom/src/nodes/html-opt-group-element/IHTMLOptGroupElement.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,12 @@ | ||
import IHTMLElement from '../html-element/IHTMLElement'; | ||
|
||
/** | ||
* HTML Opt Group Element. | ||
* | ||
* Reference: | ||
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptGroupElement. | ||
*/ | ||
export default interface IHTMLOptGroupElement extends IHTMLElement { | ||
disabled: boolean; | ||
label: string; | ||
} |
117 changes: 117 additions & 0 deletions
117
packages/happy-dom/src/nodes/html-option-element/HTMLOptionElement.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,117 @@ | ||
import HTMLElement from '../html-element/HTMLElement'; | ||
import IHTMLElement from '../html-element/IHTMLElement'; | ||
import IHTMLFormElement from '../html-form-element/IHTMLFormElement'; | ||
import HTMLOptionElementValueSanitizer from './HTMLOptionElementValueSanitizer'; | ||
import IHTMLOptionElement from './IHTMLOptionElement'; | ||
|
||
/** | ||
* HTML Option Element. | ||
* | ||
* Reference: | ||
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement. | ||
*/ | ||
export default class HTMLOptionElement extends HTMLElement implements IHTMLOptionElement { | ||
public _index: number; | ||
|
||
/** | ||
* Returns inner text, which is the rendered appearance of text. | ||
* | ||
* @returns Inner text. | ||
*/ | ||
public get text(): string { | ||
return this.innerText; | ||
} | ||
|
||
/** | ||
* Sets the inner text, which is the rendered appearance of text. | ||
* | ||
* @param innerText Inner text. | ||
*/ | ||
public set text(text: string) { | ||
this.innerText = text; | ||
} | ||
|
||
/** | ||
* Returns index. | ||
* | ||
* @returns Index. | ||
*/ | ||
public get index(): number { | ||
return this._index; | ||
} | ||
|
||
/** | ||
* Returns the parent form element. | ||
* | ||
* @returns Form. | ||
*/ | ||
public get form(): IHTMLFormElement { | ||
let parent = <IHTMLElement>this.parentNode; | ||
while (parent && parent.tagName !== 'FORM') { | ||
parent = <IHTMLElement>parent.parentNode; | ||
} | ||
return <IHTMLFormElement>parent; | ||
} | ||
|
||
/** | ||
* Returns selected. | ||
* | ||
* @returns Selected. | ||
*/ | ||
public get selected(): boolean { | ||
return this.getAttributeNS(null, 'selected') !== null; | ||
} | ||
|
||
/** | ||
* Sets selected. | ||
* | ||
* @param selected Selected. | ||
*/ | ||
public set selected(selected: boolean) { | ||
if (!selected) { | ||
this.removeAttributeNS(null, 'selected'); | ||
} else { | ||
this.setAttributeNS(null, 'selected', ''); | ||
} | ||
} | ||
|
||
/** | ||
* Returns disabled. | ||
* | ||
* @returns Disabled. | ||
*/ | ||
public get disabled(): boolean { | ||
return this.getAttributeNS(null, 'disabled') !== null; | ||
} | ||
|
||
/** | ||
* Sets disabled. | ||
* | ||
* @param disabled Disabled. | ||
*/ | ||
public set disabled(disabled: boolean) { | ||
if (!disabled) { | ||
this.removeAttributeNS(null, 'disabled'); | ||
} else { | ||
this.setAttributeNS(null, 'disabled', ''); | ||
} | ||
} | ||
|
||
/** | ||
* Returns value. | ||
* | ||
* @returns Value. | ||
*/ | ||
public get value(): string { | ||
return this.getAttributeNS(null, 'value') || ''; | ||
} | ||
|
||
/** | ||
* Sets value. | ||
* | ||
* @param value Value. | ||
*/ | ||
public set value(value: string) { | ||
this.setAttributeNS(null, 'value', HTMLOptionElementValueSanitizer.sanitize(value)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/happy-dom/src/nodes/html-option-element/HTMLOptionElementValueSanitizer.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,15 @@ | ||
const NEW_LINES_REGEXP = /[\n\r]/gm; | ||
|
||
/** | ||
* HTML select element value sanitizer. | ||
*/ | ||
export default class HTMLOptionElementValueSanitizer { | ||
/** | ||
* Sanitizes a value. | ||
* | ||
* @param value Value. | ||
*/ | ||
public static sanitize(value: string): string { | ||
return value.trim().replace(NEW_LINES_REGEXP, ''); | ||
} | ||
} |
Oops, something went wrong.