Skip to content

Commit

Permalink
chore: [#1079] Continues on implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 committed Oct 6, 2024
1 parent 30c050b commit 612ae4a
Show file tree
Hide file tree
Showing 46 changed files with 6,633 additions and 670 deletions.
48 changes: 46 additions & 2 deletions packages/happy-dom/src/PropertySymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const mode = Symbol('mode');
export const host = Symbol('host');
export const setURL = Symbol('setURL');
export const localName = Symbol('localName');
export const registedClass = Symbol('registedClass');
export const classRegistry = Symbol('classRegistry');
export const nodeStream = Symbol('nodeStream');
export const location = Symbol('location');
export const history = Symbol('history');
Expand Down Expand Up @@ -235,7 +235,6 @@ export const windowInternalId = Symbol('windowInternalId');
export const getItemList = Symbol('getItemList');
export const requiredExtensions = Symbol('requiredExtensions');
export const systemLanguage = Symbol('systemLanguage');
export const attributeSeparator = Symbol('attributeSeparator');
export const transform = Symbol('transform');
export const baseVal = Symbol('baseVal');
export const animVal = Symbol('animVal');
Expand Down Expand Up @@ -323,3 +322,48 @@ export const attributeValue = Symbol('attributeValue');
export const startOffset = Symbol('startOffset');
export const method = Symbol('method');
export const spacing = Symbol('spacing');
export const in1 = Symbol('in1');
export const in2 = Symbol('in2');
export const result = Symbol('result');
export const bias = Symbol('bias');
export const divisor = Symbol('divisor');
export const edgeMode = Symbol('edgeMode');
export const kernelMatrix = Symbol('kernelMatrix');
export const kernelUnitLengthX = Symbol('kernelUnitLengthX');
export const kernelUnitLengthY = Symbol('kernelUnitLengthY');
export const orderX = Symbol('orderX');
export const orderY = Symbol('orderY');
export const preserveAlpha = Symbol('preserveAlpha');
export const targetX = Symbol('targetX');
export const targetY = Symbol('targetY');
export const diffuseConstant = Symbol('diffuseConstant');
export const surfaceScale = Symbol('surfaceScale');
export const scale = Symbol('scale');
export const xChannelSelector = Symbol('xChannelSelector');
export const yChannelSelector = Symbol('yChannelSelector');
export const azimuth = Symbol('azimuth');
export const elevation = Symbol('elevation');
export const dx = Symbol('dx');
export const dy = Symbol('dy');
export const stdDeviationX = Symbol('stdDeviationX');
export const stdDeviationY = Symbol('stdDeviationY');
export const tableValues = Symbol('tableValues');
export const slope = Symbol('slope');
export const intercept = Symbol('intercept');
export const amplitude = Symbol('amplitude');
export const exponent = Symbol('exponent');
export const crossOrigin = Symbol('crossOrigin');
export const operator = Symbol('operator');
export const radiusX = Symbol('radiusX');
export const radiusY = Symbol('radiusY');
export const specularConstant = Symbol('specularConstant');
export const specularExponent = Symbol('specularExponent');
export const pointsAtX = Symbol('pointsAtX');
export const pointsAtY = Symbol('pointsAtY');
export const pointsAtZ = Symbol('pointsAtZ');
export const limitingConeAngle = Symbol('limitingConeAngle');
export const baseFrequencyX = Symbol('baseFrequencyX');
export const baseFrequencyY = Symbol('baseFrequencyY');
export const numOctaves = Symbol('numOctaves');
export const seed = Symbol('seed');
export const stitchTiles = Symbol('stitchTiles');
184 changes: 122 additions & 62 deletions packages/happy-dom/src/config/ISVGElementTagNameMap.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,127 @@
import SVGSVGElement from '../nodes/svg-svg-element/SVGSVGElement.js';
import SVGElement from '../nodes/svg-element/SVGElement.js';
import SVGAnimateElement from '../nodes/svg-animate-element/SVGAnimateElement.js';
import SVGAnimateMotionElement from '../nodes/svg-animate-motion-element/SVGAnimateMotionElement.js';
import SVGAnimateTransformElement from '../nodes/svg-animate-transform-element/SVGAnimateTransformElement.js';
import SVGCircleElement from '../nodes/svg-circle-element/SVGCircleElement.js';
import SVGClipPathElement from '../nodes/svg-clip-path-element/SVGClipPathElement.js';
import SVGDefsElement from '../nodes/svg-defs-element/SVGDefsElement.js';
import SVGDescElement from '../nodes/svg-desc-element/SVGDescElement.js';
import SVGEllipseElement from '../nodes/svg-ellipse-element/SVGEllipseElement.js';
import SVGFEBlendElement from '../nodes/svg-fe-blend-element/SVGFEBlendElement.js';
import SVGFEColorMatrixElement from '../nodes/svg-fe-color-matrix-element/SVGFEColorMatrixElement.js';
import SVGFEComponentTransferElement from '../nodes/svg-fe-component-transfer-element/SVGFEComponentTransferElement.js';
import SVGFECompositeElement from '../nodes/svg-fe-composite-element/SVGFECompositeElement.js';
import SVGFEConvolveMatrixElement from '../nodes/svg-fe-convolve-matrix-element/SVGFEConvolveMatrixElement.js';
import SVGFEDiffuseLightingElement from '../nodes/svg-fe-diffuse-lighting-element/SVGFEDiffuseLightingElement.js';
import SVGFEDisplacementMapElement from '../nodes/svg-fe-displacement-map-element/SVGFEDisplacementMapElement.js';
import SVGFEDistantLightElement from '../nodes/svg-fe-distant-light-element/SVGFEDistantLightElement.js';
import SVGFEDropShadowElement from '../nodes/svg-fe-drop-shadow-element/SVGFEDropShadowElement.js';
import SVGFEFloodElement from '../nodes/svg-fe-flood-element/SVGFEFloodElement.js';
import SVGFEFuncAElement from '../nodes/svg-fe-func-a-element/SVGFEFuncAElement.js';
import SVGFEFuncBElement from '../nodes/svg-fe-func-b-element/SVGFEFuncBElement.js';
import SVGFEFuncGElement from '../nodes/svg-fe-func-g-element/SVGFEFuncGElement.js';
import SVGFEFuncRElement from '../nodes/svg-fe-func-r-element/SVGFEFuncRElement.js';
import SVGFEGaussianBlurElement from '../nodes/svg-fe-gaussian-blur-element/SVGFEGaussianBlurElement.js';
import SVGFEImageElement from '../nodes/svg-fe-image-element/SVGFEImageElement.js';
import SVGFEMergeElement from '../nodes/svg-fe-merge-element/SVGFEMergeElement.js';
import SVGFEMergeNodeElement from '../nodes/svg-fe-merge-node-element/SVGFEMergeNodeElement.js';
import SVGFEMorphologyElement from '../nodes/svg-fe-morphology-element/SVGFEMorphologyElement.js';
import SVGFEOffsetElement from '../nodes/svg-fe-offset-element/SVGFEOffsetElement.js';
import SVGFEPointLightElement from '../nodes/svg-fe-point-light-element/SVGFEPointLightElement.js';
import SVGFESpecularLightingElement from '../nodes/svg-fe-specular-lighting-element/SVGFESpecularLightingElement.js';
import SVGFESpotLightElement from '../nodes/svg-fe-spot-light-element/SVGFESpotLightElement.js';
import SVGFETileElement from '../nodes/svg-fe-tile-element/SVGFETileElement.js';
import SVGFETurbulenceElement from '../nodes/svg-fe-turbulence-element/SVGFETurbulenceElement.js';
import SVGFilterElement from '../nodes/svg-filter-element/SVGFilterElement.js';
import SVGForeignObjectElement from '../nodes/svg-foreign-object-element/SVGForeignObjectElement.js';
import SVGGElement from '../nodes/svg-g-element/SVGGElement.js';
import SVGImageElement from '../nodes/svg-image-element/SVGImageElement.js';
import SVGLineElement from '../nodes/svg-line-element/SVGLineElement.js';
import SVGLinearGradientElement from '../nodes/svg-linear-gradient-element/SVGLinearGradientElement.js';
import SVGMarkerElement from '../nodes/svg-marker-element/SVGMarkerElement.js';
import SVGMaskElement from '../nodes/svg-mask-element/SVGMaskElement.js';
import SVGMetadataElement from '../nodes/svg-metadata-element/SVGMetadataElement.js';
import SVGMPathElement from '../nodes/svg-m-path-element/SVGMPathElement.js';
import SVGPathElement from '../nodes/svg-path-element/SVGPathElement.js';
import SVGPatternElement from '../nodes/svg-pattern-element/SVGPatternElement.js';
import SVGPolygonElement from '../nodes/svg-polygon-element/SVGPolygonElement.js';
import SVGPolylineElement from '../nodes/svg-polyline-element/SVGPolylineElement.js';
import SVGRadialGradientElement from '../nodes/svg-radial-gradient-element/SVGRadialGradientElement.js';
import SVGRectElement from '../nodes/svg-rect-element/SVGRectElement.js';
import SVGScriptElement from '../nodes/svg-script-element/SVGScriptElement.js';
import SVGSetElement from '../nodes/svg-set-element/SVGSetElement.js';
import SVGStopElement from '../nodes/svg-stop-element/SVGStopElement.js';
import SVGStyleElement from '../nodes/svg-style-element/SVGStyleElement.js';
import SVGSwitchElement from '../nodes/svg-switch-element/SVGSwitchElement.js';
import SVGSymbolElement from '../nodes/svg-symbol-element/SVGSymbolElement.js';
import SVGTextElement from '../nodes/svg-text-element/SVGTextElement.js';
import SVGTextPathElement from '../nodes/svg-text-path-element/SVGTextPathElement.js';
import SVGTitleElement from '../nodes/svg-title-element/SVGTitleElement.js';
import SVGTSpanElement from '../nodes/svg-t-span-element/SVGTSpanElement.js';
import SVGUseElement from '../nodes/svg-use-element/SVGUseElement.js';
import SVGViewElement from '../nodes/svg-view-element/SVGViewElement.js';

export default interface ISVGElementTagNameMap {
svg: SVGSVGElement;
animate: SVGElement;
animateMotion: SVGElement;
animateTransform: SVGElement;
circle: SVGElement;
clipPath: SVGElement;
defs: SVGElement;
desc: SVGElement;
ellipse: SVGElement;
feBlend: SVGElement;
feColorMatrix: SVGElement;
feComponentTransfer: SVGElement;
feComposite: SVGElement;
feConvolveMatrix: SVGElement;
feDiffuseLighting: SVGElement;
feDisplacementMap: SVGElement;
feDistantLight: SVGElement;
feDropShadow: SVGElement;
feFlood: SVGElement;
feFuncA: SVGElement;
feFuncB: SVGElement;
feFuncG: SVGElement;
feFuncR: SVGElement;
feGaussianBlur: SVGElement;
feImage: SVGElement;
feMerge: SVGElement;
feMergeNode: SVGElement;
feMorphology: SVGElement;
feOffset: SVGElement;
fePointLight: SVGElement;
feSpecularLighting: SVGElement;
feSpotLight: SVGElement;
feTile: SVGElement;
feTurbulence: SVGElement;
filter: SVGElement;
foreignObject: SVGElement;
g: SVGElement;
image: SVGElement;
line: SVGElement;
linearGradient: SVGElement;
marker: SVGElement;
mask: SVGElement;
metadata: SVGElement;
mpath: SVGElement;
path: SVGElement;
pattern: SVGElement;
polygon: SVGElement;
polyline: SVGElement;
radialGradient: SVGElement;
rect: SVGElement;
script: SVGElement;
set: SVGElement;
stop: SVGElement;
style: SVGElement;
switch: SVGElement;
symbol: SVGElement;
text: SVGElement;
textPath: SVGElement;
title: SVGElement;
tspan: SVGElement;
use: SVGElement;
view: SVGElement;
animate: SVGAnimateElement;
animateMotion: SVGAnimateMotionElement;
animateTransform: SVGAnimateTransformElement;
circle: SVGCircleElement;
clipPath: SVGClipPathElement;
defs: SVGDefsElement;
desc: SVGDescElement;
ellipse: SVGEllipseElement;
feBlend: SVGFEBlendElement;
feColorMatrix: SVGFEColorMatrixElement;
feComponentTransfer: SVGFEComponentTransferElement;
feComposite: SVGFECompositeElement;
feConvolveMatrix: SVGFEConvolveMatrixElement;
feDiffuseLighting: SVGFEDiffuseLightingElement;
feDisplacementMap: SVGFEDisplacementMapElement;
feDistantLight: SVGFEDistantLightElement;
feDropShadow: SVGFEDropShadowElement;
feFlood: SVGFEFloodElement;
feFuncA: SVGFEFuncAElement;
feFuncB: SVGFEFuncBElement;
feFuncG: SVGFEFuncGElement;
feFuncR: SVGFEFuncRElement;
feGaussianBlur: SVGFEGaussianBlurElement;
feImage: SVGFEImageElement;
feMerge: SVGFEMergeElement;
feMergeNode: SVGFEMergeNodeElement;
feMorphology: SVGFEMorphologyElement;
feOffset: SVGFEOffsetElement;
fePointLight: SVGFEPointLightElement;
feSpecularLighting: SVGFESpecularLightingElement;
feSpotLight: SVGFESpotLightElement;
feTile: SVGFETileElement;
feTurbulence: SVGFETurbulenceElement;
filter: SVGFilterElement;
foreignObject: SVGForeignObjectElement;
g: SVGGElement;
image: SVGImageElement;
line: SVGLineElement;
linearGradient: SVGLinearGradientElement;
marker: SVGMarkerElement;
mask: SVGMaskElement;
metadata: SVGMetadataElement;
mpath: SVGMPathElement;
path: SVGPathElement;
pattern: SVGPatternElement;
polygon: SVGPolygonElement;
polyline: SVGPolylineElement;
radialGradient: SVGRadialGradientElement;
rect: SVGRectElement;
script: SVGScriptElement;
set: SVGSetElement;
stop: SVGStopElement;
style: SVGStyleElement;
switch: SVGSwitchElement;
symbol: SVGSymbolElement;
text: SVGTextElement;
textPath: SVGTextPathElement;
title: SVGTitleElement;
tspan: SVGTSpanElement;
use: SVGUseElement;
view: SVGViewElement;
}
64 changes: 64 additions & 0 deletions packages/happy-dom/src/config/SVGElementConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
export default <{ [key: string]: string }>{
svg: 'SVGSVGElement',
animate: 'SVGAnimateElement',
animateMotion: 'SVGAnimateMotionElement',
animateTransform: 'SVGAnimateTransformElement',
circle: 'SVGCircleElement',
clipPath: 'SVGClipPathElement',
defs: 'SVGDefsElement',
desc: 'SVGDescElement',
ellipse: 'SVGEllipseElement',
feBlend: 'SVGFEBlendElement',
feColorMatrix: 'SVGFEColorMatrixElement',
feComponentTransfer: 'SVGFEComponentTransferElement',
feComposite: 'SVGFECompositeElement',
feConvolveMatrix: 'SVGFEConvolveMatrixElement',
feDiffuseLighting: 'SVGFEDiffuseLightingElement',
feDisplacementMap: 'SVGFEDisplacementMapElement',
feDistantLight: 'SVGFEDistantLightElement',
feDropShadow: 'SVGFEDropShadowElement',
feFlood: 'SVGFEFloodElement',
feFuncA: 'SVGFEFuncAElement',
feFuncB: 'SVGFEFuncBElement',
feFuncG: 'SVGFEFuncGElement',
feFuncR: 'SVGFEFuncRElement',
feGaussianBlur: 'SVGFEGaussianBlurElement',
feImage: 'SVGFEImageElement',
feMerge: 'SVGFEMergeElement',
feMergeNode: 'SVGFEMergeNodeElement',
feMorphology: 'SVGFEMorphologyElement',
feOffset: 'SVGFEOffsetElement',
fePointLight: 'SVGFEPointLightElement',
feSpecularLighting: 'SVGFESpecularLightingElement',
feSpotLight: 'SVGFESpotLightElement',
feTile: 'SVGFETileElement',
feTurbulence: 'SVGFETurbulenceElement',
filter: 'SVGFilterElement',
foreignObject: 'SVGForeignObjectElement',
g: 'SVGGElement',
image: 'SVGImageElement',
line: 'SVGLineElement',
linearGradient: 'SVGLinearGradientElement',
marker: 'SVGMarkerElement',
mask: 'SVGMaskElement',
metadata: 'SVGMetadataElement',
mpath: 'SVGMPathElement',
path: 'SVGPathElement',
pattern: 'SVGPatternElement',
polygon: 'SVGPolygonElement',
polyline: 'SVGPolylineElement',
radialGradient: 'SVGRadialGradientElement',
rect: 'SVGRectElement',
script: 'SVGScriptElement',
set: 'SVGSetElement',
stop: 'SVGStopElement',
style: 'SVGStyleElement',
switch: 'SVGSwitchElement',
symbol: 'SVGSymbolElement',
text: 'SVGTextElement',
textPath: 'SVGTextPathElement',
title: 'SVGTitleElement',
tspan: 'SVGTSpanElement',
use: 'SVGUseElement',
view: 'SVGViewElement'
};
10 changes: 5 additions & 5 deletions packages/happy-dom/src/custom-element/CustomElementRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class CustomElementRegistry {
public [PropertySymbol.registry]: {
[k: string]: { elementClass: typeof HTMLElement; extends: string };
} = {};
public [PropertySymbol.registedClass]: Map<typeof HTMLElement, string> = new Map();
public [PropertySymbol.classRegistry]: Map<typeof HTMLElement, string> = new Map();
public [PropertySymbol.callbacks]: Map<string, Array<() => void>> = new Map();
public [PropertySymbol.destroyed]: boolean = false;
#window: BrowserWindow;
Expand Down Expand Up @@ -57,7 +57,7 @@ export default class CustomElementRegistry {
);
}

if (this[PropertySymbol.registedClass].has(elementClass)) {
if (this[PropertySymbol.classRegistry].has(elementClass)) {
throw new this.#window.DOMException(
"Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry"
);
Expand All @@ -75,7 +75,7 @@ export default class CustomElementRegistry {
elementClass,
extends: options && options.extends ? options.extends.toLowerCase() : null
};
this[PropertySymbol.registedClass].set(elementClass, name);
this[PropertySymbol.classRegistry].set(elementClass, name);

// ObservedAttributes should only be called once by CustomElementRegistry (see #117)
elementClass[PropertySymbol.observedAttributes] = (elementClass.observedAttributes || []).map(
Expand Down Expand Up @@ -152,7 +152,7 @@ export default class CustomElementRegistry {
* @returns Found tag name or `null`.
*/
public getName(elementClass: typeof HTMLElement): string | null {
return this[PropertySymbol.registedClass].get(elementClass) || null;
return this[PropertySymbol.classRegistry].get(elementClass) || null;
}

/**
Expand All @@ -168,7 +168,7 @@ export default class CustomElementRegistry {
entity.elementClass.prototype[PropertySymbol.namespaceURI] = null;
}
this[PropertySymbol.registry] = {};
this[PropertySymbol.registedClass] = new Map();
this[PropertySymbol.classRegistry] = new Map();
this[PropertySymbol.callbacks] = new Map();
}

Expand Down
Loading

0 comments on commit 612ae4a

Please sign in to comment.