In the “Sharing Features Over Data Channels” section there is this example code:
const featureFunctions = { audio: function() { const status = document.querySelector('#videos #status'); // reveal "Remote peer is muted" message if muted (aria-hidden=false) // otherwise hide it (aria-hidden=true) status.setAttribute('aria-hidden', $peer.features.audio); } }
From the context it is not clear that this object literal actually needs to be defined inside the addFeaturesChannel function for it to work. This is because it references peer
and not $peer
- meaning that it relies on a local variable from the outer function.