-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak some samples for clarity and better behavior in playgrounds #148
base: main
Are you sure you want to change the base?
Conversation
When opening the existing `elementRef.focus()` examples in their frameworks’ playgrounds, the call to `.focus()` would be ignored because of `<iframe>` reasons or something. This change no longer seems like it’s broken when attempting to view it, and as a bonus it gets rid of the ambiguity between which frameworks used `type="text"` and which omitted it (Was it because the framework needs explicit attributes with default values, or because some example authors preferred to leave it off?)
The `lightIndex` selection logic can be simplified, which seems like a net win for the goal of this site; less attention on the non-framework-specific parts means more attention on the differences between components.
Since most framework playgrounds output into an `<iframe>`, their `document.title` properties end up being the empty string unless set by the component code. This made the samples look broken when loaded into playgrounds, so instead this uses runtime properties that every `<iframe>` can’t help but have.
These are some things that bothered me enough to try improving them while working on adding Marko to the framework comparison. If you’re down with the changes, I can quickly follow this up with that, but if you’d rather not, I’ll update the eventual Marko PR to stay consistent. |
I chose
It bothers me that it does not work well in playgrounds... Sacrificing readability and therefore comprehension to work inside an |
About <script>
import { onMount } from "svelte";
onMount(() => {
console.log(document.getElementById("website").value)
});
</script>
<input id="website" value="Component Party" /> But it's not a recommended way to use the DOM, and it's mixing with |
I agree with your point about For the DOM ref example purposes, one way to go would be a property/method that interacts with the element that isn’t settable as an HTML attribute. Some possibilities:
|
Like you, I would be very happy that Marko is featured in CP.
What do you think ? |
I’m happy to change the Marko code samples to match the others to get it in. (Sorry about how long this is taking — I got laid off by eBay shortly after I opened these PRs.) To be clear, the issues with |
b55f4a6
to
fa0b9af
Compare
Since most framework playgrounds output into an
<iframe>
, theirdocument.title
properties end up being the empty string unless set by the component code. This made the samples look broken when loaded into playgrounds, so instead this uses runtime properties that every<iframe>
can’t help but have.The
lightIndex
selection logic can be simplified, which seems like a net win for the goal of this site; less attention on the non-framework-specific parts means more attention on the differences between components..focus()
for DOM refsWhen opening the existing
elementRef.focus()
examples in their frameworks’ playgrounds, the call to.focus()
would be ignored because of<iframe>
reasons or something. This change no longer seems like it’s broken when attempting to view it, and as a bonus it gets rid of the ambiguity between which frameworks usedtype="text"
and which omitted it (Was it because the framework needs explicit attributes with default values, or because some example authors preferred to leave it off?)