createElement('button', {is: 'google-cast-button'}) doesn't work
Reported by
jws.f...@gmail.com,
May 16 2018
|
|||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36 Example URL: https://codepen.io/acroyear/pen/wjEEQq Steps to reproduce the problem: 1. Create a web page and include the v1 CAF framework script. 2. Use document.createElement to create a google-cast-button using the proper standard syntax of {is: 'google-cast-button} instead of just the string alone, which is based on an older version of the specification. What is the expected behavior? It should still work just like the string version. What went wrong? It doesn't work. you get an empty button. Does it occur on multiple sites: N/A Is it a problem with a plugin? N/A Did this work before? N/A Does this work in other browsers? N/A Chrome version: 66.0.3359.139 Channel: stable OS Version: OS X 10.12.6 Flash Version: Shockwave Flash 29.0 r0 This is a problem in using react.js - react is translating the syntax from the JSX into a createElement call using the standard's syntax, which Chrome documentation says should be supported, but it clearly doesn't work. This means that I have to create the button (the 'wrong' way) by hand and insert it into the DOM and it means I don't get the full benefit of many of the features of react frameworks like Material-UI.
,
May 16 2018
,
May 16 2018
gcast framework registers google-cast-button with the old API, document.registerElement(). So you can create it only with the old syntax, document.createElement('button', 'google-cast-button').
The standard syntax supports only elements registered by window.customElements.define().
,
May 16 2018
So when will this upgrade and follow the updated API instead of the ancient one? As I said, it is causing problems when other libraries presume that the standard syntax works in all 'is' cases?
,
May 16 2018
Route to cast team.
,
May 16 2018
Context: I'm writing a PWA music player app (in react and material-ui) and would like to have the cast button on the screen rather than having the user route through the settings on Google Home. Currently I have to hack around react using the {is: } syntax by creating the button myself, and in doing so, I can't get material-ui to style it correctly so I have to hack that aspect as well.
,
May 16 2018
Able to reproduce the issue on Mac 10.13.3, Win-10 and Ubuntu 17.10 using chrome reported version #66.0.3359.139 and latest canary #68.0.3431.0. This is a non-regression issue as it is observed from M60 old builds. Hence, marking it as untriaged to get more inputs from dev team. Thanks...!!
,
May 29 2018
We'll file an internal bug against the relevant team to follow up. Thanks for the report.
,
May 30 2018
,
May 31 2018
For those hitting this as well, my workaround approach is to have a ChromecastButton component that just renders a normal button inside a div with what classNames I want, then
componentDidMount() {
const button = this.myRef.current.firstChild;
// const castButton = document.createElement('button', {is: 'google-cast-button'});
// SHOULD work, but doesn't.
const castButton = document.createElement('button', 'google-cast-button');
castButton.className = button.className;
this.myRef.current.replaceChild(castButton, button);
}
that takes the button and swaps it out with the newly created cast button that works. you generally shouldn't need your own event handlers on the button to swap out because the whole point is to have google-cast-button just magically do it all for you. if needed, you can swap out style attribute as well.
,
Jun 13 2018
We've been able to reproduce the issue and will be releasing an update for the Cast Web Sender SDK soon along with updates in the documentation.
,
Jun 19 2018
neosapien@: Please update this issue when the new sender SDK has been merged into M68.
,
Jul 14
We've just added a new launcher element consistent with the new webcomponent syntax. <google-cast-launcher></google-cast-launcher> or document.createElement('google-cast-launcher')
The old button will still work but if you're using react or the new custom element syntax you can use the new element. We will update the developer docs to reflect this change.
,
Jul 14
already working for me (including in react). thanks.
,
Aug 2
,
Aug 2
|
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by jws.f...@gmail.com
, May 16 2018