Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same Class Name Cause Problem #6

Open
MJEdwin opened this issue Apr 11, 2018 · 1 comment
Open

Same Class Name Cause Problem #6

MJEdwin opened this issue Apr 11, 2018 · 1 comment

Comments

@MJEdwin
Copy link

MJEdwin commented Apr 11, 2018

    <script>
        (function (window) {
            var root = {};
            function Number() { };

            Number.prototype.show = function () {
                console.log("this is root.Number not window.Number");
            };

            root.Number = Number;

            window.test = root;

        })(window);
    </script>
    <script>
        (function (window) {
            console.log(Number === test.Number); //false

            var funcTest = overload([test.Number], function (num) {
                num.show();
            }).when([Number], function (num) {
                console.log(num);
            });

            funcTest(1); //error TypeError: num.show is not a function
        })(window);
    </script>
@MJEdwin
Copy link
Author

MJEdwin commented Apr 11, 2018

How about Use obj.constructor === type to solve this problem in Overload.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant