Skip to content

Commit

Permalink
chore: [#1629] Continues on implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 committed Jan 14, 2025
1 parent c6dfc35 commit 50acb39
Show file tree
Hide file tree
Showing 8 changed files with 1,020 additions and 307 deletions.
20 changes: 20 additions & 0 deletions packages/happy-dom/src/config/ForeignAttributeConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import NamespaceURI from './NamespaceURI.js';

/**
* Forgeign attribute config.
*
* @see https://html.spec.whatwg.org/multipage/parsing.html#adjust-foreign-attributes
*/
export default <{ [key: string]: string }>{
'xlink:actuate': NamespaceURI.xlink,
'xlink:arcrole': NamespaceURI.xlink,
'xlink:href': NamespaceURI.xlink,
'xlink:role': NamespaceURI.xlink,
'xlink:show': NamespaceURI.xlink,
'xlink:title': NamespaceURI.xlink,
'xlink:type': NamespaceURI.xlink,
'xml:lang': NamespaceURI.xml,
'xml:space': NamespaceURI.xml,
xmlns: NamespaceURI.xmlns,
'xmlns:xlink': NamespaceURI.xmlns
};
81 changes: 45 additions & 36 deletions packages/happy-dom/src/config/HTMLElementConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ export default <
className: string;
contentModel: HTMLElementConfigContentModelEnum;
forbiddenDescendants?: string[];
permittedDescendants?: string[];
permittedParents?: string[];
addPermittedParent?: string;
moveForbiddenDescendant?: { exclude: string[] };
escapesSVGNamespace?: boolean;
};
}
Expand Down Expand Up @@ -133,7 +129,7 @@ export default <
},
caption: {
className: 'HTMLTableCaptionElement',
contentModel: HTMLElementConfigContentModelEnum.textOrComments
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
cite: {
className: 'HTMLElement',
Expand All @@ -146,13 +142,11 @@ export default <
},
col: {
className: 'HTMLTableColElement',
contentModel: HTMLElementConfigContentModelEnum.noDescendants,
permittedParents: ['colgroup']
contentModel: HTMLElementConfigContentModelEnum.noDescendants
},
colgroup: {
className: 'HTMLTableColElement',
contentModel: HTMLElementConfigContentModelEnum.permittedDescendants,
permittedDescendants: ['col']
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
data: {
className: 'HTMLDataElement',
Expand Down Expand Up @@ -357,7 +351,41 @@ export default <
},
p: {
className: 'HTMLParagraphElement',
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
contentModel: HTMLElementConfigContentModelEnum.noForbiddenFirstLevelDescendants,
forbiddenDescendants: [
'address',
'article',
'aside',
'blockquote',
'details',
'div',
'dl',
'fieldset',
'figcaption',
'figure',
'footer',
'form',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'header',
'hgroup',
'hr',
'main',
'menu',
'nav',
'ol',
'pre',
'search',
'section',
'table',
'ul',
'p'
],
appendElementForNonMatchingEndTag: true,
escapesSVGNamespace: true
},
param: {
Expand Down Expand Up @@ -456,43 +484,28 @@ export default <
},
table: {
className: 'HTMLTableElement',
contentModel: HTMLElementConfigContentModelEnum.permittedDescendants,
permittedDescendants: ['caption', 'colgroup', 'thead', 'tfoot', 'tbody'],
moveForbiddenDescendant: { exclude: [] },
contentModel: HTMLElementConfigContentModelEnum.anyDescendants,
escapesSVGNamespace: true
},
tbody: {
className: 'HTMLTableSectionElement',
contentModel: HTMLElementConfigContentModelEnum.permittedDescendants,
permittedDescendants: ['tr'],
permittedParents: ['table'],
moveForbiddenDescendant: { exclude: ['caption', 'colgroup', 'thead', 'tfoot', 'tbody'] }
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
td: {
className: 'HTMLTableCellElement',
contentModel: HTMLElementConfigContentModelEnum.noForbiddenFirstLevelDescendants,
forbiddenDescendants: ['td', 'th', 'tr', 'tbody', 'tfoot', 'thead'],
permittedParents: ['tr']
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
tfoot: {
className: 'HTMLTableSectionElement',
contentModel: HTMLElementConfigContentModelEnum.permittedDescendants,
permittedDescendants: ['tr'],
permittedParents: ['table'],
moveForbiddenDescendant: { exclude: ['caption', 'colgroup', 'thead', 'tfoot', 'tbody'] }
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
th: {
className: 'HTMLTableCellElement',
contentModel: HTMLElementConfigContentModelEnum.noForbiddenFirstLevelDescendants,
forbiddenDescendants: ['td', 'th', 'tr', 'tbody', 'tfoot', 'thead'],
permittedParents: ['tr']
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
thead: {
className: 'HTMLTableSectionElement',
contentModel: HTMLElementConfigContentModelEnum.permittedDescendants,
permittedDescendants: ['tr'],
permittedParents: ['table'],
moveForbiddenDescendant: { exclude: ['caption', 'colgroup', 'thead', 'tfoot', 'tbody'] }
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
time: {
className: 'HTMLTimeElement',
Expand All @@ -504,11 +517,7 @@ export default <
},
tr: {
className: 'HTMLTableRowElement',
contentModel: HTMLElementConfigContentModelEnum.permittedDescendants,
permittedDescendants: ['td', 'th'],
permittedParents: ['tbody', 'tfoot', 'thead'],
addPermittedParent: 'tbody',
moveForbiddenDescendant: { exclude: ['caption', 'colgroup', 'thead', 'tfoot', 'tbody', 'tr'] }
contentModel: HTMLElementConfigContentModelEnum.anyDescendants
},
track: {
className: 'HTMLTrackElement',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ enum HTMLElementConfigContentModelEnum {
noFirstLevelSelfDescendants = 'noFirstLevelSelfDescendants',
noForbiddenFirstLevelDescendants = 'noForbiddenFirstLevelDescendants',
noDescendants = 'noDescendants',
permittedDescendants = 'permittedDescendants',
textOrComments = 'textOrComments',
anyDescendants = 'anyDescendants'
}

Expand Down
8 changes: 8 additions & 0 deletions packages/happy-dom/src/config/MathMLAttributeConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Math ML attribute config.
*
* @see https://html.spec.whatwg.org/multipage/parsing.html#adjust-mathml-attributes
*/
export default <{ [key: string]: string }>{
definitionurl: 'definitionURL'
};
65 changes: 65 additions & 0 deletions packages/happy-dom/src/config/SVGAttributeConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* SVG attribute config.
*
* @see https://html.spec.whatwg.org/multipage/parsing.html#adjust-svg-attributes
*/
export default <{ [key: string]: string }>{
attributename: 'attributeName',
attributetype: 'attributeType',
basefrequency: 'baseFrequency',
baseprofile: 'baseProfile',
calcmode: 'calcMode',
clippathunits: 'clipPathUnits',
diffuseconstant: 'diffuseConstant',
edgemode: 'edgeMode',
filterunits: 'filterUnits',
glyphref: 'glyphRef',
gradienttransform: 'gradientTransform',
gradientunits: 'gradientUnits',
kernelmatrix: 'kernelMatrix',
kernelunitlength: 'kernelUnitLength',
keypoints: 'keyPoints',
keysplines: 'keySplines',
keytimes: 'keyTimes',
lengthadjust: 'lengthAdjust',
limitingconeangle: 'limitingConeAngle',
markerheight: 'markerHeight',
markerunits: 'markerUnits',
markerwidth: 'markerWidth',
maskcontentunits: 'maskContentUnits',
maskunits: 'maskUnits',
numoctaves: 'numOctaves',
pathlength: 'pathLength',
patterncontentunits: 'patternContentUnits',
patterntransform: 'patternTransform',
patternunits: 'patternUnits',
pointsatx: 'pointsAtX',
pointsaty: 'pointsAtY',
pointsatz: 'pointsAtZ',
preservealpha: 'preserveAlpha',
preserveaspectratio: 'preserveAspectRatio',
primitiveunits: 'primitiveUnits',
refx: 'refX',
refy: 'refY',
repeatcount: 'repeatCount',
repeatdur: 'repeatDur',
requiredextensions: 'requiredExtensions',
requiredfeatures: 'requiredFeatures',
specularconstant: 'specularConstant',
specularexponent: 'specularExponent',
spreadmethod: 'spreadMethod',
startoffset: 'startOffset',
stddeviation: 'stdDeviation',
stitchtiles: 'stitchTiles',
surfacescale: 'surfaceScale',
systemlanguage: 'systemLanguage',
tablevalues: 'tableValues',
targetx: 'targetX',
targety: 'targetY',
textlength: 'textLength',
viewbox: 'viewBox',
viewtarget: 'viewTarget',
xchannelselector: 'xChannelSelector',
ychannelselector: 'yChannelSelector',
zoomandpan: 'zoomAndPan'
};
Loading

0 comments on commit 50acb39

Please sign in to comment.