Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [#1629] Multiple fixes to DOM parsing #1666

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/happy-dom/src/PropertySymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export const scrollWidth = Symbol('scrollWidth');
export const scrollTop = Symbol('scrollTop');
export const scrollLeft = Symbol('scrollLeft');
export const attributes = Symbol('attributes');
export const attributesProxy = Symbol('attributesProxy');
export const namespaceURI = Symbol('namespaceURI');
export const accessKey = Symbol('accessKey');
export const accessKeyLabel = Symbol('accessKeyLabel');
Expand Down Expand Up @@ -376,6 +375,7 @@ export const rotate = Symbol('rotate');
export const bindMethods = Symbol('bindMethods');
export const xmlProcessingInstruction = Symbol('xmlProcessingInstruction');
export const root = Symbol('root');
export const filterNode = Symbol('filterNode');
export const customElementReactionStack = Symbol('customElementReactionStack');
export const isRemoved = Symbol('isRemoved');
export const currentNode = Symbol('currentNode');
export const dispatching = Symbol('dispatching');
115 changes: 77 additions & 38 deletions packages/happy-dom/src/config/HTMLElementConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default <
permittedParents?: string[];
addPermittedParent?: string;
moveForbiddenDescendant?: { exclude: string[] };
escapesSVGNamespace?: boolean;
};
}
>{
Expand Down Expand Up @@ -46,7 +47,8 @@ export default <
},
b: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
base: {
className: 'HTMLBaseElement',
Expand All @@ -62,7 +64,8 @@ export default <
},
body: {
className: 'HTMLBodyElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
template: {
className: 'HTMLTemplateElement',
Expand All @@ -86,7 +89,8 @@ export default <
},
img: {
className: 'HTMLImageElement',
contentModel: HTMLElementConfigContentModelEnum.noDescendants
contentModel: HTMLElementConfigContentModelEnum.noDescendants,
escapesSVGNamespace: true
},
link: {
className: 'HTMLLinkElement',
Expand All @@ -106,15 +110,18 @@ export default <
},
meta: {
className: 'HTMLMetaElement',
contentModel: HTMLElementConfigContentModelEnum.noDescendants
contentModel: HTMLElementConfigContentModelEnum.noDescendants,
escapesSVGNamespace: true
},
blockquote: {
className: 'HTMLQuoteElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
br: {
className: 'HTMLBRElement',
contentModel: HTMLElementConfigContentModelEnum.noDescendants
contentModel: HTMLElementConfigContentModelEnum.noDescendants,
escapesSVGNamespace: true
},
button: {
className: 'HTMLButtonElement',
Expand All @@ -134,7 +141,8 @@ export default <
},
code: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
col: {
className: 'HTMLTableColElement',
Expand All @@ -157,7 +165,8 @@ export default <
dd: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.noForbiddenFirstLevelDescendants,
forbiddenDescendants: ['dt', 'dd']
forbiddenDescendants: ['dt', 'dd'],
escapesSVGNamespace: true
},
del: {
className: 'HTMLModElement',
Expand All @@ -177,24 +186,29 @@ export default <
},
div: {
className: 'HTMLDivElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
dl: {
className: 'HTMLDListElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
dt: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.noForbiddenFirstLevelDescendants,
forbiddenDescendants: ['dt', 'dd']
forbiddenDescendants: ['dt', 'dd'],
escapesSVGNamespace: true
},
em: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
embed: {
className: 'HTMLEmbedElement',
contentModel: HTMLElementConfigContentModelEnum.noDescendants
contentModel: HTMLElementConfigContentModelEnum.noDescendants,
escapesSVGNamespace: true
},
fieldset: {
className: 'HTMLFieldSetElement',
Expand All @@ -214,31 +228,38 @@ export default <
},
h1: {
className: 'HTMLHeadingElement',
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants,
escapesSVGNamespace: true
},
h2: {
className: 'HTMLHeadingElement',
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants,
escapesSVGNamespace: true
},
h3: {
className: 'HTMLHeadingElement',
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants,
escapesSVGNamespace: true
},
h4: {
className: 'HTMLHeadingElement',
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants,
escapesSVGNamespace: true
},
h5: {
className: 'HTMLHeadingElement',
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants,
escapesSVGNamespace: true
},
h6: {
className: 'HTMLHeadingElement',
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants,
escapesSVGNamespace: true
},
head: {
className: 'HTMLHeadElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
header: {
className: 'HTMLElement',
Expand All @@ -250,15 +271,17 @@ export default <
},
hr: {
className: 'HTMLHRElement',
contentModel: HTMLElementConfigContentModelEnum.noDescendants
contentModel: HTMLElementConfigContentModelEnum.noDescendants,
escapesSVGNamespace: true
},
html: {
className: 'HTMLHtmlElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
i: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
iframe: {
className: 'HTMLIFrameElement',
Expand All @@ -278,7 +301,8 @@ export default <
},
li: {
className: 'HTMLLIElement',
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants
contentModel: HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants,
escapesSVGNamespace: true
},
main: {
className: 'HTMLElement',
Expand All @@ -294,7 +318,8 @@ export default <
},
menu: {
className: 'HTMLMenuElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
meter: {
className: 'HTMLMeterElement',
Expand All @@ -314,7 +339,8 @@ export default <
},
ol: {
className: 'HTMLOListElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
optgroup: {
className: 'HTMLOptGroupElement',
Expand All @@ -331,7 +357,8 @@ export default <
},
p: {
className: 'HTMLParagraphElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
param: {
className: 'HTMLParamElement',
Expand All @@ -343,7 +370,8 @@ export default <
},
pre: {
className: 'HTMLPreElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
progress: {
className: 'HTMLProgressElement',
Expand Down Expand Up @@ -373,11 +401,13 @@ export default <
},
ruby: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
s: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
samp: {
className: 'HTMLElement',
Expand All @@ -393,37 +423,43 @@ export default <
},
small: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
source: {
className: 'HTMLSourceElement',
contentModel: HTMLElementConfigContentModelEnum.noDescendants
},
span: {
className: 'HTMLSpanElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
strong: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
sub: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
summary: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
sup: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
table: {
className: 'HTMLTableElement',
contentModel: HTMLElementConfigContentModelEnum.permittedDescendants,
permittedDescendants: ['caption', 'colgroup', 'thead', 'tfoot', 'tbody'],
moveForbiddenDescendant: { exclude: [] }
moveForbiddenDescendant: { exclude: [] },
escapesSVGNamespace: true
},
tbody: {
className: 'HTMLTableSectionElement',
Expand Down Expand Up @@ -480,15 +516,18 @@ export default <
},
u: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
ul: {
className: 'HTMLUListElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
var: {
className: 'HTMLElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
video: {
className: 'HTMLVideoElement',
Expand Down
44 changes: 44 additions & 0 deletions packages/happy-dom/src/config/MathMLElementConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @see https://w3c.github.io/mathml-core/
* @see https://developer.mozilla.org/en-US/docs/Web/MathML/Element
*/
export default <
{
[key: string]: boolean;
}
>{
'annotation-xml': true,
annotation: true,
maction: true,
math: true,
menclose: true,
merror: true,
mfenced: true,
mfrac: true,
mglyph: true,
mi: true,
mlabeledtr: true,
mmultiscripts: true,
mn: true,
mo: true,
mover: true,
mpadded: true,
mphantom: true,
mprescripts: true,
mroot: true,
mrow: true,
ms: true,
mspace: true,
msqrt: true,
mstyle: true,
msub: true,
msubsup: true,
msup: true,
mtable: true,
mtd: true,
mtext: true,
mtr: true,
munder: true,
munderover: true,
semantics: true
};
Loading
Loading