Skip to content

Commit

Permalink
Merge pull request #688 from takaya1992/task/652-bugfix-dataset-prope…
Browse files Browse the repository at this point in the history
…rty-delete-when-property-not-exists

#652@patch: Fixed deleting not exist dataset properties.
  • Loading branch information
capricorn86 committed Jan 12, 2023
2 parents 67d95f0 + 0365a44 commit 13b1580
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/happy-dom/src/nodes/html-element/HTMLElement.ts
Expand Up @@ -251,10 +251,9 @@ export default class HTMLElement extends Element implements IHTMLElement {
},
deleteProperty: (dataset: { [key: string]: string }, key: string) => {
const name = 'data-' + DatasetUtility.camelCaseToKebab(key);
const exists = !!attributes[name];
delete attributes[name];
delete dataset[key];
return exists;
const result1 = delete attributes[name];
const result2 = delete dataset[key];
return result1 && result2;
},
ownKeys: (dataset: { [key: string]: string }) => {
// According to Mozilla we have to update the dataset object (target) to contain the same keys as what we return:
Expand Down

0 comments on commit 13b1580

Please sign in to comment.