v0.19.0
Explicit Element Construction
Element construction now separates serialized element data from Ruby constructor options and makes the intended construction path explicit.
Live::Element#initializenow requires bothidanddata. ReplaceMyView.newwithMyView.root, and replaceMyView.new("custom-id")withMyView.root("custom-id"). Internal callers usingnewdirectly must pass the data hash explicitly, even when empty.Live::Element.root,.child, and.mountnow accept serialized attributes throughdata:. Other keyword arguments are forwarded toinitialize. For example, changeMyView.root(mode: "presenter")toMyView.root(data: {mode: "presenter"}); constructor dependencies such ascontroller:can remain ordinary keyword arguments.- Calls passing a positional data hash to
.mountmust use thedata:keyword. ChangeChildView.mount(parent, "child", {mode: "compact"})toChildView.mount(parent, "child", data: {mode: "compact"}). Live::Resolver#root(view_class, id = view_class.unique_id, data: {}, **options)constructs an allowed root using the same internal path as browser-resolved elements. Custom resolvers that inject dependencies can override the privatemake(view_class, id, data, **options)method instead of overridingcall.