Add Inline Source Support
evanplaice opened this issue · 3 comments
Add the ability to load the source from an inline <script>
tag
<wc-monaco-editor language="javascript">
<script type="wc-content">
function myGoodPerson(){
return "what can I do for you ?"
}
</script>
</wc-monaco-editor>
just swimming by here! i tried to use the value
attribute but it didnt seem to work:
<wc-monaco-editor language="javascript" value="let foo = 123">
</wc-monaco-editor>
was this the intended use? is inline source support something different?
That doesn't work because 'value' is a property not an HTML attribute. It's only assignable via JavaScript.
To answer your question. Yes, the inline source feature is intended for declaratively defining the initial value of the editor declaratively in HTML.
Generally, I've found 4 useful strategies for setting complex data on a standard web component.
- attributes (HTML)
- properties (JS)
- inline (HTML)
- fetch
I just need to implement inline source support for this element. It makes a lot more sense for general use. Fetch works great but adds a lot of overhead, especially on pages with many instances of this component.
ok think i got it. thank you!