Skip to content

Commit aa4c194

Browse files
committedJan 29, 2024
fix(utils): Modify getOwnPropertyDescriptor to hasOwnProperty prototype function
1 parent 9a1ba81 commit aa4c194

9 files changed

+29
-19
lines changed
 

‎dist/purify.cjs.js

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.mjs

+5-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ function addToSet(set, array) {
120120
*/
121121
function cleanArray(array) {
122122
for (let index = 0; index < array.length; index++) {
123-
if (getOwnPropertyDescriptor(array, index) === undefined) {
123+
const isHasOwnProperty = Object.prototype.hasOwnProperty.call(array, index);
124+
if (!isHasOwnProperty) {
124125
array[index] = null;
125126
}
126127
}
@@ -136,7 +137,8 @@ function cleanArray(array) {
136137
function clone(object) {
137138
const newObject = create(null);
138139
for (const [property, value] of entries(object)) {
139-
if (getOwnPropertyDescriptor(object, property) !== undefined) {
140+
const isHasOwnProperty = Object.prototype.hasOwnProperty.call(object, property);
141+
if (isHasOwnProperty) {
140142
if (Array.isArray(value)) {
141143
newObject[property] = cleanArray(value);
142144
} else if (value && typeof value === 'object' && value.constructor === Object) {
@@ -169,8 +171,7 @@ function lookupGetter(object, prop) {
169171
}
170172
object = getPrototypeOf(object);
171173
}
172-
function fallbackValue(element) {
173-
console.warn('fallback value for', element);
174+
function fallbackValue() {
174175
return null;
175176
}
176177
return fallbackValue;

‎dist/purify.es.mjs.map

+1-1
Large diffs are not rendered by default.

‎dist/purify.js

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/utils.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ function addToSet(set, array, transformCaseFunc = stringToLowerCase) {
115115
*/
116116
function cleanArray(array) {
117117
for (let index = 0; index < array.length; index++) {
118-
if (getOwnPropertyDescriptor(array, index) === undefined) {
118+
const isHasOwnProperty = Object.prototype.hasOwnProperty.call(array, index);
119+
120+
if (!isHasOwnProperty) {
119121
array[index] = null;
120122
}
121123
}
@@ -133,7 +135,12 @@ function clone(object) {
133135
const newObject = create(null);
134136

135137
for (const [property, value] of entries(object)) {
136-
if (getOwnPropertyDescriptor(object, property) !== undefined) {
138+
const isHasOwnProperty = Object.prototype.hasOwnProperty.call(
139+
object,
140+
property
141+
);
142+
143+
if (isHasOwnProperty) {
137144
if (Array.isArray(value)) {
138145
newObject[property] = cleanArray(value);
139146
} else if (

0 commit comments

Comments
 (0)
Please sign in to comment.