Skip to content

Commit 8c819e5

Browse files
committed
unused
1 parent a59f18a commit 8c819e5

File tree

1 file changed

+1
-116
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/transform-template

1 file changed

+1
-116
lines changed
Lines changed: 1 addition & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @import { Node } from './types.js' */
2-
/** @import { ObjectExpression, Identifier, ArrayExpression, Property, Expression, Literal } from 'estree' */
32
import * as b from '../../../../utils/builders.js';
4-
import { regex_is_valid_identifier, regex_starts_with_newline } from '../../../patterns.js';
3+
import { regex_starts_with_newline } from '../../../patterns.js';
54
import fix_attribute_casing from './fix-attribute-casing.js';
65

76
/**
@@ -74,117 +73,3 @@ function build(item) {
7473
}
7574
}
7675
}
77-
78-
/**
79-
* @typedef {ObjectExpression} Element
80-
*/
81-
82-
/**
83-
* @typedef {void | null | ArrayExpression} Anchor
84-
*/
85-
86-
/**
87-
* @typedef {void | Literal} Text
88-
*/
89-
90-
/**
91-
* @typedef { Element | Anchor| Text } Node
92-
*/
93-
94-
/**
95-
* @param {string} element
96-
* @returns {Element}
97-
*/
98-
function create_element(element) {
99-
return b.object([b.prop('init', b.id('e'), b.literal(element))]);
100-
}
101-
102-
/**
103-
*
104-
* @param {Element} element
105-
* @param {string} name
106-
* @param {Expression} init
107-
* @returns {Property}
108-
*/
109-
function get_or_create_prop(element, name, init) {
110-
let prop = element.properties.find(
111-
(prop) => prop.type === 'Property' && /** @type {Identifier} */ (prop.key).name === name
112-
);
113-
if (!prop) {
114-
prop = b.prop('init', b.id(name), init);
115-
element.properties.push(prop);
116-
}
117-
return /** @type {Property} */ (prop);
118-
}
119-
120-
/**
121-
* @param {Element} element
122-
* @param {string} data
123-
* @returns {Anchor}
124-
*/
125-
function create_anchor(element, data = '') {
126-
if (!element) return data ? b.array([b.literal(data)]) : null;
127-
const c = get_or_create_prop(element, 'c', b.array([]));
128-
/** @type {ArrayExpression} */ (c.value).elements.push(data ? b.array([b.literal(data)]) : null);
129-
}
130-
131-
/**
132-
* @param {Element} element
133-
* @param {string} value
134-
* @returns {Text}
135-
*/
136-
function create_text(element, value) {
137-
if (!element) return b.literal(value);
138-
139-
// TODO this is temporary, but i want the tests to keep passing in the meantime
140-
// @ts-expect-error
141-
const name = element?.properties[0].value.value;
142-
143-
if ((name === 'pre' || name === 'textarea') && regex_starts_with_newline.test(value)) {
144-
// @ts-expect-error
145-
if (!element.properties.find((prop) => prop.key.name === 'c')) {
146-
value = value.replace(regex_starts_with_newline, '');
147-
}
148-
}
149-
150-
const c = get_or_create_prop(element, 'c', b.array([]));
151-
/** @type {ArrayExpression} */ (c.value).elements.push(b.literal(value));
152-
}
153-
154-
/**
155-
*
156-
* @param {Element} element
157-
* @param {string} prop
158-
* @param {string | undefined} value
159-
*/
160-
function set_prop(element, prop, value) {
161-
const p = get_or_create_prop(element, 'p', b.object([]));
162-
163-
if (prop === 'is') {
164-
element.properties.push(b.prop('init', b.id(prop), b.literal(/** @type {string} */ (value))));
165-
return;
166-
}
167-
168-
const prop_correct_case = fix_attribute_casing(prop);
169-
170-
const is_valid_id = regex_is_valid_identifier.test(prop_correct_case);
171-
172-
/** @type {ObjectExpression} */ (p.value).properties.push(
173-
b.prop(
174-
'init',
175-
(is_valid_id ? b.id : b.literal)(prop_correct_case),
176-
b.literal(value),
177-
!is_valid_id
178-
)
179-
);
180-
}
181-
182-
/**
183-
*
184-
* @param {Element} element
185-
* @param {Expression | null} child
186-
*/
187-
function insert(element, child) {
188-
const c = get_or_create_prop(element, 'c', b.array([]));
189-
/** @type {ArrayExpression} */ (c.value).elements.push(child);
190-
}

0 commit comments

Comments
 (0)