Jump to content

Bug in Tags module


Majeed Siddiqui
 Share

Recommended Posts

BabylonJS's Tag module uses https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.tags.js#L63

for (var i in arr) {
...
}

looping style, this gives error when we add custom methods to array prototype as follows

Array.prototype.sayCheese = function () {
    console.log("Cheese!!");
}
// with above sayCheese added
var arr[] = ['majeed', 'found', 'a', 'bug'];
for (var i in arr) {
  console.log(arr[i]);
}

// output:
// majeed
// found
// a
// bug
// function Array.prototype.sayCheese() {} [not string a function object]

Which result in i.trim is not a function exception in Tags._AddTagTo function https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.tags.js#L68.

Solution: use for (var i = 0, len = arr.length; i < len; ++i) traditional loop (http://stackoverflow.com/questions/5349425/whats-the-fastest-way-to-loop-through-an-array-in-javascript)

I want to contribute. Is there contribution guide or should I just make changes and make a pull request?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...