MCPcopy
hub / github.com/livebud/bud / dom

Function dom

package/svelte/compiler.js:22195–22645  ·  view source on GitHub ↗
(component, options)

Source from the content-addressed store, hash-verified

22193 return typeof enable_sourcemap === "boolean" ? enable_sourcemap : enable_sourcemap[namespace];
22194 }
22195 function dom(component, options) {
22196 const { name } = component;
22197 const renderer = new Renderer(component, options);
22198 const { block } = renderer;
22199 block.has_outro_method = true;
22200 if (options.customElement)
22201 block.chunks.create.push(b`this.c = @noop;`);
22202 const body = [];
22203 if (renderer.file_var) {
22204 const file = component.file ? x`"${component.file}"` : x`undefined`;
22205 body.push(b`const ${renderer.file_var} = ${file};`);
22206 }
22207 const css = component.stylesheet.render(options.filename, !options.customElement);
22208 const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, "css");
22209 if (css_sourcemap_enabled) {
22210 css.map = apply_preprocessor_sourcemap(options.filename, css.map, options.sourcemap);
22211 } else {
22212 css.map = null;
22213 }
22214 const styles = css_sourcemap_enabled && component.stylesheet.has_styles && options.dev ? `${css.code}
22215/*# sourceMappingURL=${css.map.toUrl()} */` : css.code;
22216 const add_css = component.get_unique_name("add_css");
22217 const should_add_css = !options.customElement && !!styles && options.css !== false;
22218 if (should_add_css) {
22219 body.push(b`
22220 function ${add_css}(target) {
22221 @append_styles(target, "${component.stylesheet.id}", "${styles}");
22222 }
22223 `);
22224 }
22225 const blocks = renderer.blocks.slice().reverse();
22226 push_array$1(body, blocks.map((block2) => {
22227 if (block2.render)
22228 return block2.render();
22229 return block2;
22230 }));
22231 if (options.dev && !options.hydratable) {
22232 block.chunks.claim.push(b`throw new @_Error("options.hydrate only works if the component was compiled with the \`hydratable: true\` option");`);
22233 }
22234 const uses_slots = component.var_lookup.has("$$slots");
22235 let compute_slots;
22236 if (uses_slots) {
22237 compute_slots = b`
22238 const $$slots = @compute_slots(#slots);
22239 `;
22240 }
22241 const uses_props = component.var_lookup.has("$$props");
22242 const uses_rest = component.var_lookup.has("$$restProps");
22243 const $$props = uses_props || uses_rest ? "$$new_props" : "$$props";
22244 const props = component.vars.filter((variable) => !variable.module && variable.export_name);
22245 const writable_props = props.filter((variable) => variable.writable);
22246 const omit_props_names = component.get_unique_name("omit_props_names");
22247 const compute_rest = x`@compute_rest_props($$props, ${omit_props_names.name})`;
22248 const rest = uses_rest ? b`
22249 const ${omit_props_names.name} = [${props.map((prop) => `"${prop.export_name}"`).join(",")}];
22250 let $$restProps = ${compute_rest};
22251 ` : null;
22252 const set = uses_props || uses_rest || writable_props.length > 0 || component.slots.size > 0 ? x`

Callers 1

compileFunction · 0.85

Calls 15

bFunction · 0.85
xFunction · 0.85
check_enable_sourcemapFunction · 0.85
push_array$1Function · 0.85
pFunction · 0.85
walkFunction · 0.85
flattenFunction · 0.85
pushMethod · 0.80
get_unique_nameMethod · 0.80
hasMethod · 0.80
invalidateMethod · 0.80

Tested by

no test coverage detected