-
-
Notifications
You must be signed in to change notification settings - Fork 56
wordWrap and (at least) readOnly properties don't seem to work #43
Comments
I've found the reason for the issue. Svelte is compiling the attributes from camel-case to lower-case before passing them to Svelte NodeGUI. This is something I'd thought we'd solved once and for all with the PRs to Svelte from @halfnelson and @mrsauravsahu to support foreign namespaces. The Svelte NodeGUI preprocessor (and Svelte Native preprocessor from which it is forked) implicitly inserts
However, Incidentally, I also tried So it has nothing to do with the values being booleans or strings. I guess Svelte must be special-casing certain attributes from the HTML5 spec, as I can't find any mentions of
I'm just surprised that this is biting us when we're in a foreign namespace. Does this analysis seem plausible @halfnelson, @mrsauravsahu? Mentioned PRs: |
A horrible workaround for now if it's blocking you: // BetterText.svelte
<script lang="ts">
import type { NSVElement, RNText } from "@nodegui/svelte-nodegui";
let ref: any;
export let wordwrap: boolean = false;
// Find some way to map out the other attributes you need.
// There is probably a clever Svelte way to extend all those of RNTextProps, but I don't know how!
$: {
if(ref){
/** With reference to the setTextProps() method in: src/dom/react-nodegui/src/components/Text/RNText.ts */
(ref as NSVElement<RNText>).nativeView.setWordWrap(wordwrap);
}
}
</script>
<text bind:this={ref}><slot></slot></text> And use like this: <script lang="ts">
import BetterText from BetterText.svelte
</script>
<BetterText wordwrap={true}>abc</BetterText> |
Far from perfect, but at least it allows to set |
Looking at the Svelte JS output of the same code in the repl (https://svelte.dev/repl/a64f21f99f3d48de992a731a76818c32?version=3.37.0) gives us a clue c() {
window_1 = document.createElementNS("https://svelte.dev/docs#svelte_options", "window");
view2 = svg_element("view");
view0 = svg_element("view");
text0 = svg_element("text");
//snip
attr(text1, "wordwrap", text1_wordwrap_value = true); The elements are being detected as and forced to SVG. There must be some code in svelte that does this which we need to skip for namespace foreign |
When trying this code:
the text widget does not wrap and the plainTextEdit is not readonly.
The text was updated successfully, but these errors were encountered: