Skip to content
Prev Previous commit
Next Next commit
reintroduce unicode oddities
  • Loading branch information
43081j committed Jun 6, 2019
commit c3b5bca33f0f080c2f8dff8560f994905c200144
14 changes: 7 additions & 7 deletions src/compiler/compile/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export default class Component {
this.source
);

const parts = module.split('✂]');
const parts = module.split(']');
const final_chunk = parts.pop();

const compiled = new Bundle({ separator: '' });
Expand All @@ -411,7 +411,7 @@ export default class Component {

const { filename } = compile_options;

// special case — the source file doesn't actually get used anywhere. we need
// special case the source file doesn't actually get used anywhere. we need
// to add an empty file to populate map.sources and map.sourcesContent
if (!parts.length) {
compiled.addSource({
Expand All @@ -420,7 +420,7 @@ export default class Component {
});
}

const pattern = /\[✂(\d+)-(\d+)$/;
const pattern = /\[(\d+)-(\d+)$/;

parts.forEach((str: string) => {
const chunk = str.replace(pattern, '');
Expand Down Expand Up @@ -644,7 +644,7 @@ export default class Component {

script.content.body.forEach((node) => {
if (this.hoistable_nodes.has(node) || this.reactive_declaration_nodes.has(node)) {
if (a !== b) result += `[✂${a}-${b}✂]`;
if (a !== b) result += `[${a}-${b}]`;
a = node.end;
}

Expand All @@ -656,7 +656,7 @@ export default class Component {
b = script.content.end;
while (/\s/.test(this.source[b - 1])) b -= 1;

if (a < b) result += `[✂${a}-${b}✂]`;
if (a < b) result += `[${a}-${b}]`;

return result || null;
}
Expand Down Expand Up @@ -1107,7 +1107,7 @@ export default class Component {
});

hoistable_nodes.add(node);
this.fully_hoisted.push(`[✂${node.start}-${node.end}✂]`);
this.fully_hoisted.push(`[${node.start}-${node.end}]`);
}
}

Expand Down Expand Up @@ -1199,7 +1199,7 @@ export default class Component {

remove_indentation(this.code, node);

this.fully_hoisted.push(`[✂${node.start}-${node.end}✂]`);
this.fully_hoisted.push(`[${node.start}-${node.end}]`);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/css/Stylesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export default class Stylesheet {
const atrule = new Atrule(node);
stack.push(atrule);

// this is an awkward special case — @apply (and
// this is an awkward special case @apply (and
// possibly other future constructs)
if (last && !(last instanceof Atrule)) return;

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/nodes/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default class Element extends Node {
}

if (this.name === 'option') {
// Special case — treat these the same way:
// Special case treat these the same way:
// <option>{foo}</option>
// <option value={foo}>{foo}</option>
const value_attribute = info.attributes.find(attribute => attribute.name === 'value');
Expand Down Expand Up @@ -547,7 +547,7 @@ export default class Element extends Node {

if (type !== 'checkbox') {
let message = `'${name}' binding can only be used with <input type="checkbox">`;
if (type === 'radio') message += ` — for <input type="radio">, use 'group' binding`;
if (type === 'radio') message += ` for <input type="radio">, use 'group' binding`;
component.error(binding, { code: `invalid-binding`, message });
}
} else if (name === 'group') {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/nodes/shared/Expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export default class Expression {
throw new Error(`Well that's odd`);
}

// TOOD optimisation — if this is an event handler,
// TOOD optimisation if this is an event handler,
// the return value doesn't matter
}

Expand Down Expand Up @@ -513,6 +513,6 @@ export default class Expression {
});
}

return this.rendered = `[✂${this.node.start}-${this.node.end}✂]`;
return this.rendered = `[${this.node.start}-${this.node.end}]`;
}
}
2 changes: 1 addition & 1 deletion src/compiler/compile/render-dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export default function dom(
})
.map(n => `$$dirty.${n}`).join(' || ');

let snippet = `[✂${d.node.body.start}-${d.node.end}✂]`;
let snippet = `[${d.node.body.start}-${d.node.end}]`;
if (condition) snippet = `if (${condition}) { ${snippet} }`;

if (condition || uses_props) {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/render-dom/wrappers/DebugTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class DebugTagWrapper extends Wrapper {
code.overwrite(this.node.start + 1, this.node.start + 7, 'debugger', {
storeName: true
});
const statement = `[✂${this.node.start + 1}-${this.node.start + 7}✂];`;
const statement = `[${this.node.start + 1}-${this.node.start + 7}];`;

block.builders.create.add_line(statement);
block.builders.update.add_line(statement);
Expand All @@ -41,7 +41,7 @@ export default class DebugTagWrapper extends Wrapper {
code.overwrite(this.node.start + 1, this.node.start + 7, 'log', {
storeName: true
});
const log = `[✂${this.node.start + 1}-${this.node.start + 7}✂]`;
const log = `[${this.node.start + 1}-${this.node.start + 7}]`;

const dependencies = new Set();
this.node.expressions.forEach(expression => {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render-dom/wrappers/Fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class FragmentWrapper {
throw new Error(`TODO implement ${child.type}`);
}

// special case — this is an easy way to remove whitespace surrounding
// special case this is an easy way to remove whitespace surrounding
// <svelte:window/>. lil hacky but it works
if (child.type === 'Window') {
window_wrapper = new Window(renderer, block, parent, child);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default class InlineComponentWrapper extends Wrapper {
let object;

if (binding.is_contextual && binding.expression.node.type === 'Identifier') {
// bind:x={y} — we can't just do `y = x`, we need to
// bind:x={y} we can't just do `y = x`, we need to
// to `array[index] = x;
const { name } = binding.expression.node;
const { snippet } = block.bindings.get(name);
Expand Down Expand Up @@ -316,7 +316,7 @@ export default class InlineComponentWrapper extends Wrapper {
let lhs = component.source.slice(binding.expression.node.start, binding.expression.node.end).trim();

if (binding.is_contextual && binding.expression.node.type === 'Identifier') {
// bind:x={y} — we can't just do `y = x`, we need to
// bind:x={y} we can't just do `y = x`, we need to
// to `array[index] = x;
const { name } = binding.expression.node;
const { object, property, snippet } = block.bindings.get(name);
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/compile/render-dom/wrappers/Title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ export default class TitleWrapper extends Wrapper {

const all_dependencies = new Set();

// TODO some of this code is repeated in Tag.ts — would be good to
// TODO some of this code is repeated in Tag.ts would be good to
// DRY it out if that's possible without introducing crazy indirection
if (this.node.children.length === 1) {
// single {tag} — may be a non-string
// single {tag} may be a non-string
// @ts-ignore todo: check this
const { expression } = this.node.children[0];
value = expression.render(block);
add_to_set(all_dependencies, expression.dependencies);
} else {
// '{foo} {bar}' — treat as string concatenation
// '{foo} {bar}' treat as string concatenation
value =
(this.node.children[0].type === 'Text' ? '' : `"" + `) +
this.node.children
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render-dom/wrappers/shared/Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class Wrapper {
}

get_or_create_anchor(block: Block, parent_node: string, parent_nodes: string) {
// TODO use this in EachBlock and IfBlock — tricky because
// TODO use this in EachBlock and IfBlock tricky because
// children need to be created first
const needs_anchor = this.next ? !this.next.is_dom_node() : !parent_node || !this.parent.is_dom_node();
const anchor = needs_anchor
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render-ssr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function ssr(
: [];

const reactive_declarations = component.reactive_declarations.map(d => {
let snippet = `[✂${d.node.body.start}-${d.node.end}✂]`;
let snippet = `[${d.node.body.start}-${d.node.end}]`;

if (d.declaration) {
const declared = extract_names(d.declaration);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/parse/state/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function read_attribute(parser: Parser, unique_names: Set<string>) {
if (type === 'Ref') {
parser.error({
code: `invalid-ref-directive`,
message: `The ref directive is no longer supported — use \`bind:this={${directive_name}}\` instead`
message: `The ref directive is no longer supported use \`bind:this={${directive_name}}\` instead`
}, start);
}

Expand Down Expand Up @@ -485,7 +485,7 @@ export default function tag(parser: Parser) {
element.expression = definition.value[0].expression;
}

// special cases – top-level <script> and <style>
// special cases - top-level <script> and <style>
if (specials.has(name) && parser.stack.length === 1) {
const special = specials.get(name);

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/parse/utils/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function validate_code(code: number) {
}

// code points 128-159 are dealt with leniently by browsers, but they're incorrect. We need
// to correct the mistake or we'll end up with missing € signs and so on
// to correct the mistake or we'll end up with missing signs and so on
if (code <= 159) {
return windows_1252[code - 128];
}
Expand Down