Jump to content
Search Community

allebrum

Members
  • Posts

    4
  • Joined

  • Last visited

allebrum's Achievements

3

Reputation

  1. I did see that you had asked why they were wanting to do it, which provides that you were willing to help further. I think that's great. First, I realize you guys answer a lot of questions, and on a whim, I probably would have responded in the same fashion. When I say meaningful, I mean answering their "assumed" question (since they didn't ask a real question), which is "Why isn't this code working, or how do I make this work." Telling them not to do it, or that it's not good practice, doesn't tell them why TweenMax is erroring out with their code. Even though the issue is very unrelated, it seems at first glance to be an issue with TweenMax. I realize it's not your job to troubleshoot their code, but explaining that "TweenMax loops through all the properties on a target object (which in this case inherits `test` from Object.prototype) and if it's a function, calls that function. What you would need to do is make `test` non-enumerable on the Object.prototype so TweenMax does not error out." From here, you could choose to explain what you see as best practices. That's my humble opinion. Cheers!
  2. I'm not here to argue about best practices. I was irritated that I landed here looking for an answer and the final response on the thread was more or less "it's bad, don't do it; nevermind that tweenmax errors out." I appreciate that GSAP places a huge priority on speed, which is why it's the only third-party javascript library that we use client-side. I didn't appreciate that someone's "best-practices" got in the way of providing a meaningful response to someone who seemed like they were trying to learn.
  3. This error seems to originate on line 5487 (well in the Chrome developer tools) where TweenMax calls any and all functions on the object, regardless if it's on the prototype chain or not. This should check if object hasOwnProperty and not call functions on the prototype chain. In the meantime, if you want to alter the Object.prototype you can define the property like so: /** * Create a shallow copy of an object while breaking all references. * Slow, but effective * let t = {a:0} * let s = t.copy(); */ if(typeof Object.prototype.copy === 'undefined'){ Object.defineProperty(Object.prototype, 'copy', { enumerable: false, get: function(){ return ()=>{ return JSON.parse(JSON.stringify(this)); } } }) }
  4. You can't just say, "That's considered a very poor practice" because it's not. The prototype is a very powerful tool when used correctly. It might be poor practice to not check to see if the Object.prototype already has a function named test. I ran into the same issue. We add several Object.prototype utilities for working with objects and TweenMax throws a heck of a fit with VERSION: 1.19.1 That is very frustrating that TweenMax will error out an entire system when you mess with the prototype of Object. That should be fixed instead of telling people not to do it.
×
×
  • Create New...