Skip to content

Erroneous "object is not frozen" warnings #7

@tdulcet

Description

@tdulcet

Originally mentioned by @rugk in #6 (comment). Users will get many of these erroneous warnings on extensions with several option groups, like the Awesome Emoji Picker, which is confusing for developers creating PRs (#6 (comment)).

This issue is the unfreezeObject() function:

function unfreezeObject(value) {
// always shallow-copy
if (Array.isArray(value)) {
value = value.slice();
} else if ((isPlainObject(value))) {
value = Object.assign({}, value);
} else {
// return primitive value or similar ones
return value;
}
// but warn if object was not even frozen, so deev can fix the default settings
if (!Object.isFrozen(value)) {
console.warn("The following defined default value of type", typeof value, "is not frozen. It is recommend that all default options are frozen.", value);
}

It checks if the objects are not frozen after doing the shallow-copy. They will of course never be frozen after the shallow-copy, which is why this warning always outputs every time the function is called with an object, regardless of whether the object was initially frozen or not...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions