misc.js — svelte Source File
Architecture documentation for misc.js, a javascript file in the svelte codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR b0dea6fe_a39b_1574_4bd3_e0f24d88074a["misc.js"] e5c35d51_28d8_9054_923d_b7f82a3c8dc2["sources.js"] b0dea6fe_a39b_1574_4bd3_e0f24d88074a --> e5c35d51_28d8_9054_923d_b7f82a3c8dc2 63ee8247_ada4_9f1d_e139_0c1167cd5b1c["set"] b0dea6fe_a39b_1574_4bd3_e0f24d88074a --> 63ee8247_ada4_9f1d_e139_0c1167cd5b1c 1e2f7428_6050_5cb7_69db_bf5db719f6d1["source"] b0dea6fe_a39b_1574_4bd3_e0f24d88074a --> 1e2f7428_6050_5cb7_69db_bf5db719f6d1 bde4209f_8ffc_1594_4024_b1835a44bcf6["runtime.js"] b0dea6fe_a39b_1574_4bd3_e0f24d88074a --> bde4209f_8ffc_1594_4024_b1835a44bcf6 a08b6cc5_af73_1be4_d02f_3113cf8a8305["get"] b0dea6fe_a39b_1574_4bd3_e0f24d88074a --> a08b6cc5_af73_1be4_d02f_3113cf8a8305 cb946435_ce66_d1e8_6bee_287bdb07e7c5["utils.js"] b0dea6fe_a39b_1574_4bd3_e0f24d88074a --> cb946435_ce66_d1e8_6bee_287bdb07e7c5 style b0dea6fe_a39b_1574_4bd3_e0f24d88074a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { set, source } from '../../reactivity/sources.js';
import { get } from '../../runtime.js';
import { is_array } from '../../../shared/utils.js';
/**
* Under some circumstances, imports may be reactive in legacy mode. In that case,
* they should be using `reactive_import` as part of the transformation
* @param {() => any} fn
*/
export function reactive_import(fn) {
var s = source(0);
return function () {
if (arguments.length === 1) {
set(s, get(s) + 1);
return arguments[0];
} else {
get(s);
return fn();
}
};
}
/**
* @this {any}
* @param {Record<string, unknown>} $$props
* @param {Event} event
* @returns {void}
*/
export function bubble_event($$props, event) {
var events = /** @type {Record<string, Function[] | Function>} */ ($$props.$$events)?.[
event.type
];
var callbacks = is_array(events) ? events.slice() : events == null ? [] : [events];
for (var fn of callbacks) {
// Preserve "this" context
fn.call(this, event);
}
}
/**
* Used to simulate `$on` on a component instance when `compatibility.componentApi === 4`
* @param {Record<string, any>} $$props
* @param {string} event_name
* @param {Function} event_callback
*/
export function add_legacy_event_listener($$props, event_name, event_callback) {
$$props.$$events ||= {};
$$props.$$events[event_name] ||= [];
$$props.$$events[event_name].push(event_callback);
}
/**
* Used to simulate `$set` on a component instance when `compatibility.componentApi === 4`.
* Needs component accessors so that it can call the setter of the prop. Therefore doesn't
* work for updating props in `$$props` or `$$restProps`.
* @this {Record<string, any>}
* @param {Record<string, any>} $$new_props
*/
export function update_legacy_props($$new_props) {
for (var key in $$new_props) {
if (key in this) {
this[key] = $$new_props[key];
}
}
}
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does misc.js do?
misc.js is a source file in the svelte codebase, written in javascript. It belongs to the ClientRuntime domain, LegacyBridge subdomain.
What functions are defined in misc.js?
misc.js defines 4 function(s): add_legacy_event_listener, bubble_event, reactive_import, update_legacy_props.
What does misc.js depend on?
misc.js imports 6 module(s): get, runtime.js, set, source, sources.js, utils.js.
Where is misc.js in the architecture?
misc.js is located at packages/svelte/src/internal/client/dom/legacy/misc.js (domain: ClientRuntime, subdomain: LegacyBridge, directory: packages/svelte/src/internal/client/dom/legacy).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free