Skip to content

Nested function cause 'strict mode' error #64

@TianhaoTong

Description

@TianhaoTong

In react-globalize/src/message.js
this code block (from line 43)

        /* eslint-disable no-inner-declarations */
        function getMessage(globalize, path) {
            return globalize.cldr.get(["globalize-messages/{bundle}"].concat(path));
        }

        function setMessage(globalize, path, message) {
            var data = {};
            function set(data, path, value) {
                var i;
                var node = data;
                var length = path.length;

                for (i = 0; i < length - 1; i++) {
                    if (!node[path[i]]) {
                        node[path[i]] = {};
                    }
                    node = node[path[i]];
                }
                node[path[i]] = value;
            }
            set(data, [globalize.cldr.attributes.bundle].concat(path), message);
            Globalize.loadMessages(data);
        }
        /* eslint-enable no-inner-declarations */

Causes PhantomJS and Firefox complaining about violation of strict mode:

SyntaxError: Functions cannot be declared in a nested block in strict mode

Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.

Verified that simply use a function expression will solve the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions