nfl / react-gpt

A React display ad component using Google Publisher Tag
MIT License
145 stars 84 forks source link

Fluid slotSize cannot be assigned due to type coercion check #72

Closed masakikomine closed 6 years ago

masakikomine commented 6 years ago
        if (Array.isArray(slotSize) && Array.isArray(slotSize[0])) {
            slotSize = slotSize[0];
        }
        // https://developers.google.com/doubleclick-gpt/reference?hl=en#googletag.NamedSize
        if (slotSize === "fluid") {
            slotSize = ["auto", "auto"];
        }

The above code in the render() of Bling.js cannot properly extract the value 'fluid' due to type coercion. For example the slotSize = [['fluid'],[1,1]] has slotSize[0] = an array object with the 'fluid' as it's 0th index value, but will evaluate to false against === "fluid" which is a string.

This could be updated to: if (slotSize === "fluid" || slotSize[0] === "fluid") and then the issue should be resolved.

potench commented 6 years ago

You're right, this should be adjusted to handle the ['fluid'] case. PR is above if you want to review it.

Note that both 'fluid' and ['fluid'] are acceptable forms to declare a slot size as fluid. https://developers.google.com/doubleclick-gpt/reference

masakikomine commented 6 years ago

Thank you @potench !