scroll-scene-element icon indicating copy to clipboard operation
scroll-scene-element copied to clipboard

Address setter compatibility with frameworks

Open rdmurphy opened this issue 4 years ago • 2 comments

I thought I did everything correctly with the custom element property setters but Svelte quickly informed me that I had in fact not.

I think the issue here is that Svelte has special handling for custom elements — if it sees that an attribute has a matching property it will pass it in as a property instead of an attribute. This is confusing because it does not do this for native DOM elements. ¯\(ツ)/¯

But anyway, this is probably a real bug with how I implemented the setter for offset. It should be possible to "unset" it by doing scene.offset = null but that crashes and burns right now.

rdmurphy avatar Mar 22 '22 17:03 rdmurphy

I think the easiest answer here may be to just not reflect the offset property to the attribute. There's precedent for that in native elements. Could just store a reference to it locally at this._offset and use that if someone passes it in (and default to 0.5 if it's null-ish). Just let the attribute path be a helpful way to define your defaults in the markup.

rdmurphy avatar Mar 22 '22 18:03 rdmurphy

Going to remove the bug tag from this because I don't think it's really a "bug" in the typical sense — this is on Svelte for trying to do something a little weird.

rdmurphy avatar Apr 13 '22 20:04 rdmurphy