Sign In

jsdom

Package Overview
Dependencies
Maintainers
6
Versions
285
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdom - npm Package Compare versions

Comparing version
29.1.0
to
29.1.1
+10
-3
lib/jsdom/living/css/CSSStyleDeclaration-impl.js

@@ -394,6 +394,13 @@ "use strict";

}
case "border":
case "border-top":
case "border-right":
case "border-bottom":
case "border-left":
case "border-width":
case "border-style":
case "border-color": {
return this.#resolveBorderShorthands(property);
}
default: {
if (property.startsWith("border")) {
return this.#resolveBorderShorthands(property);
}
return value;

@@ -400,0 +407,0 @@ }

@@ -102,5 +102,7 @@ "use strict";

function handleRule(ruleImpl, elementImpl, declaration, specificities) {
const { ast, match } = matches(ruleImpl.selectorText, elementImpl);
if (match) {
handleStyle(ruleImpl.style, declaration, specificities, ast);
if (ruleMightMatchElement(ruleImpl, elementImpl)) {
const { ast, match } = matches(ruleImpl.selectorText, elementImpl);
if (match) {
handleStyle(ruleImpl.style, declaration, specificities, ast);
}
}

@@ -143,2 +145,40 @@ }

function ruleMightMatchElement(ruleImpl, elementImpl) {
if (!ruleImpl._selectorSubjects) {
const domSelector = elementImpl._ownerDocument._getDOMSelector();
ruleImpl._selectorSubjects =
domSelector.extractSubjects(
ruleImpl.selectorText,
elementImpl._ownerDocument.contentType !== "text/html"
);
}
const subjects = ruleImpl._selectorSubjects;
if (subjects.length === 0) {
return true;
}
const id = elementImpl.getAttributeNS(null, "id");
const { classList } = elementImpl;
// TODO: Remove toLowerCase() after updating the dom-selector.
const tag = elementImpl._localName.toLowerCase();
for (const keys of subjects) {
let mightMatch = true;
if (keys.id && keys.id !== id) {
mightMatch = false;
} else if (keys.className && !classList.contains(keys.className)) {
mightMatch = false;
// TODO: Remove toLowerCase() after updating the dom-selector.
} else if (keys.tag && keys.tag.toLowerCase() !== tag) {
mightMatch = false;
}
if (mightMatch) {
return true;
}
}
return false;
}
function matches(selectorText, elementImpl) {

@@ -145,0 +185,0 @@ const domSelector = elementImpl._ownerDocument._getDOMSelector();

@@ -237,2 +237,3 @@ "use strict";

clipValue === background.initialValues.get("background-clip");
let boxSet = false;
for (const longhand of background.initialValues.keys()) {

@@ -243,10 +244,13 @@ const value = bgValue[longhand];

}
if (longhand === "background-origin") {
if (!isDefaultBox) {
bg.push(originValue);
if (longhand === "background-origin" || longhand === "background-clip") {
if (isDefaultBox || boxSet) {
continue;
} else {
if (originValue === clipValue) {
bg.push(originValue);
} else {
bg.push(originValue, clipValue);
}
boxSet = true;
}
} else if (longhand === "background-clip") {
if (!isDefaultBox && originValue !== clipValue) {
bg.push(clipValue);
}
} else if (value !== background.initialValues.get(longhand)) {

@@ -253,0 +257,0 @@ if (longhand === "background-position") {

@@ -197,2 +197,3 @@ "use strict";

clipValue === initialValues.get(backgroundClip.property);
let boxSet = false;
for (const [longhand] of shorthandFor) {

@@ -209,10 +210,13 @@ let value;

}
if (longhand === backgroundOrigin.property) {
if (!isDefaultBox) {
bg.push(originValue);
if (longhand === backgroundOrigin.property || longhand === backgroundClip.property) {
if (isDefaultBox || boxSet) {
continue;
} else {
if (originValue === clipValue) {
bg.push(originValue);
} else {
bg.push(originValue, clipValue);
}
boxSet = true;
}
} else if (longhand === backgroundClip.property) {
if (!isDefaultBox && originValue !== clipValue) {
bg.push(clipValue);
}
} else if (longhand === backgroundColor.property) {

@@ -290,3 +294,2 @@ if (i === l - 1 && (value !== initialValues.get(longhand) || bgMap.has(longhand))) {

const bgRepeat = [];
const bgBox = [];
const bgParts = parsers.splitValue(values[i], {

@@ -300,2 +303,3 @@ delimiter: "/"

const parts1 = parsers.splitValue(bgPart1);
let originFilled = false;
for (const part of parts1) {

@@ -307,10 +311,17 @@ let partValid = false;

switch (longhand) {
case backgroundClip.property:
case backgroundOrigin.property: {
case backgroundClip.property: {
const parsedValue = value.parse(part);
if (parsedValue) {
bgBox.push(parsedValue);
bg[longhand] = parsedValue;
}
break;
}
case backgroundOrigin.property: {
const parsedValue = value.parse(part);
if (parsedValue && !originFilled) {
bg[longhand] = parsedValue;
originFilled = true;
}
break;
}
case backgroundColor.property: {

@@ -364,10 +375,17 @@ if (i !== values.length - 1) {

switch (longhand) {
case backgroundClip.property:
case backgroundOrigin.property: {
case backgroundClip.property: {
const parsedValue = value.parse(part);
if (parsedValue) {
bgBox.push(parsedValue);
bg[longhand] = parsedValue;
}
break;
}
case backgroundOrigin.property: {
const parsedValue = value.parse(part);
if (parsedValue && !originFilled) {
bg[longhand] = parsedValue;
originFilled = true;
}
break;
}
case backgroundColor.property: {

@@ -435,21 +453,2 @@ if (i !== l - 1) {

}
if (bgBox.length) {
switch (bgBox.length) {
case 1: {
const [value] = bgBox;
bg[backgroundOrigin.property] = value;
bg[backgroundClip.property] = value;
break;
}
case 2: {
const [value1, value2] = bgBox;
bg[backgroundOrigin.property] = value1;
bg[backgroundClip.property] = value2;
break;
}
default: {
return undefined;
}
}
}
bgValues.push(bg);

@@ -456,0 +455,0 @@ }

{
"name": "jsdom",
"version": "29.1.0",
"version": "29.1.1",
"description": "A JavaScript implementation of many web standards",

@@ -5,0 +5,0 @@ "keywords": [