remove unused second argument to source, and runtime immutable option to createRoot (not sure what that was doing there?)

proxied-state-each-blocks
Rich Harris 11 months ago
parent 84a30b55cd
commit ccc47a0747

@ -2606,7 +2606,6 @@ export function spread_props(props) {
* events?: Events; * events?: Events;
* context?: Map<any, any>; * context?: Map<any, any>;
* intro?: boolean; * intro?: boolean;
* immutable?: boolean;
* recover?: false; * recover?: false;
* }} options * }} options
* @returns {Exports & { $destroy: () => void; $set: (props: Partial<Props>) => void; }} * @returns {Exports & { $destroy: () => void; $set: (props: Partial<Props>) => void; }}
@ -2624,15 +2623,8 @@ export function createRoot(component, options) {
* @param {any} value * @param {any} value
*/ */
function add_prop(name, value) { function add_prop(name, value) {
const prop = source( const prop = source(value);
value, prop.e = safe_equal; // TODO should this be default_equal?
options.immutable
? /**
* @param {any} a
* @param {any} b
*/ (a, b) => a === b
: safe_equal
);
_sources[name] = prop; _sources[name] = prop;
define_property(_props, name, { define_property(_props, name, {
get() { get() {
@ -2666,11 +2658,10 @@ export function createRoot(component, options) {
return _props[property]; return _props[property];
} }
}); });
const props_source = source( const props_source = source(props_proxy);
props_proxy,
// We're resetting the same proxy instance for updates, therefore bypass equality checks // We're resetting the same proxy instance for updates, therefore bypass equality checks
() => false props_source.e = safe_equal;
);
let [accessors, $destroy] = mount(component, { let [accessors, $destroy] = mount(component, {
...options, ...options,

@ -1142,25 +1142,20 @@ export function derived(init) {
/** /**
* @template V * @template V
* @param {V} initial_value * @param {V} initial_value
* @param {import('./types.js').EqualsFunctions<V>} [equals]
* @returns {import('./types.js').SourceSignal<V>} * @returns {import('./types.js').SourceSignal<V>}
*/ */
/*#__NO_SIDE_EFFECTS__*/ /*#__NO_SIDE_EFFECTS__*/
export function source(initial_value, equals) { export function source(initial_value) {
const source = create_source_signal(SOURCE | CLEAN, initial_value); const source = create_source_signal(SOURCE | CLEAN, initial_value);
source.x = current_component_context; source.x = current_component_context;
source.e = get_equals_method(equals); source.e = get_equals_method();
return source; return source;
} }
/** /**
* @param {import('./types.js').EqualsFunctions} [equals]
* @returns {import('./types.js').EqualsFunctions} * @returns {import('./types.js').EqualsFunctions}
*/ */
function get_equals_method(equals) { function get_equals_method() {
if (equals !== undefined) {
return equals;
}
const context = current_component_context; const context = current_component_context;
if (context && !context.i) { if (context && !context.i) {
return safe_equal; return safe_equal;

@ -68,7 +68,6 @@ class Svelte4Component {
target: options.target, target: options.target,
props: { ...options.props, $$events: this.#events }, props: { ...options.props, $$events: this.#events },
context: options.context, context: options.context,
immutable: options.immutable,
intro: options.intro, intro: options.intro,
recover: options.recover recover: options.recover
}); });

Loading…
Cancel
Save