Convert src/compiler/compile/css/Selector.ts to JavaScript

pull/8569/head
Simon Holthausen 3 years ago
parent ae3c8ed08b
commit 4cb02a5a02

File diff suppressed because it is too large Load Diff

@ -4,7 +4,7 @@ import Selector from './Selector';
import Element from '../nodes/Element';
import { Ast, CssHashGetter } from '../../interfaces';
import Component from '../Component';
import { CssNode } from './interfaces';
import { CssNode } from './private';
import hash from '../utils/hash';
import compiler_warnings from '../compiler_warnings';
import { extract_ignores_above_position } from '../../utils/extract_svelte_ignore';

@ -1,8 +1,10 @@
import { Node } from 'estree';
export const UNKNOWN = {};
export function gather_possible_values(node: Node, set: Set<string | {}>) {
/**
* @param {import("estree").Node} node
* @param {Set<string | {}>} set
*/
export function gather_possible_values(node, set) {
if (node.type === 'Literal') {
set.add(node.value);
} else if (node.type === 'ConditionalExpression') {

@ -16,7 +16,7 @@ export default class Block {
* @property {Block} [parent]
* @property {import('estree').Identifier} name
* @property {string} type
* @property {import('./Renderer.js').default} renderer
* @property {import('./Renderer.js').default} [renderer]
* @property {string} [comment]
* @property {import('estree').Identifier} [key]
* @property {Map<string,Bindings>} [bindings]

@ -11,13 +11,14 @@ import { push_array } from '../../utils/push_array.js';
/**
* @param {import('../Component.js').default} component
* @param {import('../../interfaces.js').CompileOptions} options
* @returns {{ js: import("C:/repos/svelte/svelte/node_modules/.pnpm/@types+estree@1.0.0/node_modules/@types/estree/index").import('estree').Node[]; css: import('../../interfaces.js').CssResult; }}
* @returns {{ js: import('estree').Node[]; css: import('../../interfaces.js').CssResult; }}
*/
export default function dom(component, options) {
const { name } = component;
const renderer = new Renderer(component, options);
const { block } = renderer;
block.has_outro_method = true;
/** @type {import('estree').Node[][]} */
const body = [];
if (renderer.file_var) {
const file = component.file ? x`"${component.file}"` : x`undefined`;
@ -537,7 +538,7 @@ export default function dom(component, options) {
if (renderer.context_overflow) {
dirty = x`[]`;
for (let i = 0; i < renderer.context.length; i += 31) {
dirty.elements.push(x`-1`);
/** @type {any} */ (dirty).elements.push(x`-1`);
}
}
const superclass = {
@ -570,7 +571,7 @@ export default function dom(component, options) {
`[0]
);
push_array(declaration.body.body, accessors);
body.push(declaration);
body.push(/** @type {any} */ (declaration));
if (options.customElement) {
const props_str = writable_props.reduce((def, prop) => {
def[prop.export_name] =

@ -7,6 +7,7 @@ import { x } from 'code-red';
* @param {import('estree').Node} node
* @param {Set<string>} names
* @param {boolean} main_execution_context
* @returns {any}
*/
export function invalidate(renderer, scope, node, names, main_execution_context = false) {
const { component } = renderer;
@ -59,6 +60,7 @@ export function invalidate(renderer, scope, node, names, main_execution_context
if (is_store_value) {
return x`@set_store_value(${head.name.slice(1)}, ${node}, ${head.name}, ${extra_args})`;
}
let invalidate;
if (!main_execution_context) {
const pass_value =
@ -88,8 +90,9 @@ export function invalidate(renderer, scope, node, names, main_execution_context
/**
* @param {import('./Renderer.js').default} renderer
* @param {string} name
* @param {unknown} [value]
* @param {any} [value]
* @param {boolean} main_execution_context
* @returns {import('estree').Node}
*/
export function renderer_invalidate(renderer, name, value, main_execution_context = false) {
const variable = renderer.component.var_lookup.get(name);

@ -531,7 +531,7 @@ export default class EachBlockWrapper extends Wrapper {
* initial_mount_node: import('estree').Identifier;
* update_anchor_node: import('estree').Identifier;
* update_mount_node: import('estree').Identifier;
* }}
* }} params
*/
render_unkeyed({
block,

@ -422,7 +422,7 @@ export default class IfBlockWrapper extends Wrapper {
* @param {import('estree').Identifier} parent_node
* @param {import('estree').Identifier} _parent_nodes
* @param {boolean} dynamic
* @param {any}
* @param {any} opts
* @param {DetachingOrNull} detaching
*/
render_compound_with_outros(
@ -609,7 +609,7 @@ export default class IfBlockWrapper extends Wrapper {
* @param {import('estree').Identifier} parent_node
* @param {import('estree').Identifier} _parent_nodes
* @param {boolean} dynamic
* @param {any}
* @param {any} opts
* @param {DetachingOrNull} detaching
*/
render_simple(

Loading…
Cancel
Save