rename create_text to text

pull/2252/head
Richard Harris 7 years ago
parent bbb5b1c57a
commit 24cb2d269f

@ -113,6 +113,7 @@ export default class Component {
aliases: Map<string, string> = new Map(); aliases: Map<string, string> = new Map();
used_names: Set<string> = new Set(); used_names: Set<string> = new Set();
globally_used_names: Set<string> = new Set();
constructor( constructor(
ast: Ast, ast: Ast,
@ -349,7 +350,8 @@ export default class Component {
let i = 1; let i = 1;
reserved.has(alias) || reserved.has(alias) ||
this.var_lookup.has(alias) || this.var_lookup.has(alias) ||
this.used_names.has(alias); this.used_names.has(alias) ||
this.globally_used_names.has(alias);
alias = `${name}_${i++}` alias = `${name}_${i++}`
); );
this.used_names.add(alias); this.used_names.add(alias);
@ -377,6 +379,7 @@ export default class Component {
alias = `${name}_${i++}` alias = `${name}_${i++}`
); );
local_used_names.add(alias); local_used_names.add(alias);
this.globally_used_names.add(alias);
return alias; return alias;
}; };
} }

@ -20,7 +20,7 @@ export default class MustacheTagWrapper extends Tag {
block.add_element( block.add_element(
this.var, this.var,
`@create_text(${init})`, `@text(${init})`,
parent_nodes && `@claim_text(${parent_nodes}, ${init})`, parent_nodes && `@claim_text(${parent_nodes}, ${init})`,
parent_node parent_node
); );

@ -54,7 +54,7 @@ export default class TextWrapper extends Wrapper {
block.add_element( block.add_element(
this.var, this.var,
`@create_text(${stringify(this.data)})`, `@text(${stringify(this.data)})`,
parent_nodes && `@claim_text(${parent_nodes}, ${stringify(this.data)})`, parent_nodes && `@claim_text(${parent_nodes}, ${stringify(this.data)})`,
parent_node parent_node
); );

@ -42,7 +42,7 @@ export function svg_element(name) {
return document.createElementNS('http://www.w3.org/2000/svg', name); return document.createElementNS('http://www.w3.org/2000/svg', name);
} }
export function create_text(data) { export function text(data) {
return document.createTextNode(data); return document.createTextNode(data);
} }
@ -146,7 +146,7 @@ export function claim_text(nodes, data) {
} }
} }
return create_text(data); return text(data);
} }
export function set_data(text, data) { export function set_data(text, data) {

@ -115,7 +115,7 @@ describe("runtime", () => {
mod = require(`./samples/${dir}/main.svelte`); mod = require(`./samples/${dir}/main.svelte`);
SvelteComponent = mod.default; SvelteComponent = mod.default;
} catch (err) { } catch (err) {
showOutput(cwd, compileOptions, svelte.compile); // eslint-disable-line no-console showOutput(cwd, compileOptions, compile); // eslint-disable-line no-console
throw err; throw err;
} }
@ -186,13 +186,13 @@ describe("runtime", () => {
} }
} else { } else {
failed.add(dir); failed.add(dir);
showOutput(cwd, compileOptions, svelte.compile); // eslint-disable-line no-console showOutput(cwd, compileOptions, compile); // eslint-disable-line no-console
throw err; throw err;
} }
}) })
.then(() => { .then(() => {
if (config.show) { if (config.show) {
showOutput(cwd, compileOptions, svelte.compile); showOutput(cwd, compileOptions, compile);
} }
flush(); flush();

@ -11,7 +11,7 @@ export default {
</svg> </svg>
`, `,
test({ assert, component, target }) { test({ assert, target }) {
const attr = sel => target.querySelector(sel).attributes[0].name; const attr = sel => target.querySelector(sel).attributes[0].name;
assert.equal(attr('div'), 'class'); assert.equal(attr('div'), 'class');

Loading…
Cancel
Save