- From: Joseph Orbegoso Pea <notifications@github.com>
- Date: Tue, 05 Sep 2017 21:12:27 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/662/327369316@github.com>
@rniwa You [said in the other thread](https://github.com/w3c/webcomponents/issues/509#issuecomment-327363604) > Yeah, that's pretty much mixins, and it makes a lot more sense than the current inheritance model of `is`. One major challenge there is defining which one wins when the two define conflicting behaviors and properties. Properties would normally be defined on the component instances. F.e. an instance of the `foo` component could have a `bar` property on it's `this`, and so can an instance of the `lorem` component. There'd be no conflict in this regard because they're separate instances. This would be the recommended way to write components. However, there could be a conflict if components assign properties onto the Element instance that is passed into the component's `constructor(el) {}` of course. In this case, there's no way to prevent conflicts. But in order to discourage developers blindly assigning properties onto an Element, there could be an API that makes it easy to get a component instance from the Element, f.e. ```js // .components is readonly, perhaps frozen or sealed const {foo} = someElement.components foo.someMethod() console.log(foo.someProperty) ``` This way it would be possible for a component author to expose public methods and for them not to clash with methods of another component. ```html <div is="audio-player" src="./foo.mp3"></div> <script> const audioDiv = document.querySelector('div[is="audio-player"]') const player = audioDiv.components['audio-player'] // or maybe, const player = audioDiv.components.audioPlayer player.pause() // ... player.resume() // ... const audioNode = player.getNode() // WebAudio API // ... connect output to another node ... </script> ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/webcomponents/issues/662#issuecomment-327369316
Received on Wednesday, 6 September 2017 04:12:50 UTC