Skip to content

getOption falsy key behavior differs from native js object #3701

Open
@taburetkin

Description

@taburetkin

Description

the getOption method have falsy check for keyName and this may lead for some unexpected results.
link to source:

if (!optionName) { return; }

example:

const falsyKey = 0;
const view = new Mn.View({ [falsyKey]: 'some value' });
console.log(view.getOption(falsyKey)) // undefined;
console.log(view.options[falsyKey]) // somev value;

the codepen: https://codepen.io/dimatabu/pen/vYWwyMR?editors=0010

solution:

const getOption = function(optionName) {
-  if (!optionName) { return; }
+ if (!arguments.length) { return; }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions