Multiple root containers question
I have a content script inserts a new root container in a website.:
I would like to add a new root container so that I can attach OilOverlay to it as well.
Right now the only one that works is the Desktop one. Replicating the code in a new content script and searching for the mobile class instead of desktop does not work.
What am I missing here?
5 Replies
@bwbama85 has reached level 1. GG!
Right now the only one that works is the Desktop one. Replicating the code in a new content script and searching for the mobile class instead of desktop does not work.Does the mobile thing always exist? I would log out the element that was querried and check. in that query function, try using a querySelectorAll and debug it out also might be beneficial to bump the timer to make it easier to see what's going on
Hi Louis,
Yes mobileOnly always exist. Its a rather old code style that has both mobile and desktop styles always on the page.
I will do a bit more debugging and see if I can figure it out. Was just making sure I wasn't making an error in how I was setting two root containers or something like that.
Note that when setting your own root container, you will need to handle how they should be rendered. The default renderer only render once for each root container. If you're returning 2 elements, you will need iterate through them to render the 2 items as needed. It's a bit weird that a 2nd content script wasn't able to see and render elements tho... these CS are separated in context. I'd console log the selector on each script to ensure there's no conflicting logic
This is the second content script:
oilPriceDesktop.tsx and oilPriceMobile.tsx inside contents folder
I'll eventually combine them into one but was separating them to ease debugging at first only to find the mobile one did not work at all.
Thanks for the guidance so far. Will keep chipping away and see what I can come up with