Jump to content
Search Community

stop warnings in empty nodelist

Thiago Kadooka test
Moderator Tag

Recommended Posts

its a simple thing, i noticed that in gsap 3, when you try to tween a empty nodelist, it gives a warning.

this is a new behavior, in gsap 2 this dosnt happen, is there a simple way to just not show this warnings in the console?

 

(yeah i could check if nodelist is empty in simple ifs, but i guess im lazy to do in all the cases, specially in my older projects)

Link to comment
Share on other sites

wassup Zach!

 

the problem is not the null warning, is actually a warning when i try to use an empty nodelist, for example:

 

gsap.to(document.querySelectorAll("whatever"), { duration:1, color: "#FFFFFF" });

this, gives me the warning:

 

Invalid property color set to #FFFFFF Missing plugin? gsap.registerPlugin()

 

 

Link to comment
Share on other sites

The problem is that i actually need to use querySelectorAll in my case, because i need to get multiple elements (that can actually be zero, one or more in the querySelectorAll).

 

querySelector returns a null if nothing is found, but querySelectorAll return a empty nodeList (with length 0).

 

i was updating my older projects to gsap 3, and then i started to get those warnings. (this dosnt happen in gsap 2)

This even happens if i try to use a jquery that finds nothing:

 

gsap.to($("whatever"), { duration:1, color: "#FFFFFF" });

 

(here on this website, if you press F12 in a pc browser and paste this line of code in the console you can already see this behavior)

 

but here a codepen anyway:

 

See the Pen vYEJNZx by tochjunin (@tochjunin) on CodePen

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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