deconflict `anchor` variable name (#4769)

pull/4772/head
Conduitry 4 years ago committed by GitHub
parent a658fedb83
commit f111cf6881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,7 @@
* Do not display a11y warning about missing `href` for `<a>` with `name` or `id` ([#4697](https://github.com/sveltejs/svelte/issues/4697)) * Do not display a11y warning about missing `href` for `<a>` with `name` or `id` ([#4697](https://github.com/sveltejs/svelte/issues/4697))
* Disable infinite loop guard inside generators ([#4698](https://github.com/sveltejs/svelte/issues/4698)) * Disable infinite loop guard inside generators ([#4698](https://github.com/sveltejs/svelte/issues/4698))
* Display a11y warning for `href="javascript:..."` ([#4733](https://github.com/sveltejs/svelte/pull/4733)) * Display a11y warning for `href="javascript:..."` ([#4733](https://github.com/sveltejs/svelte/pull/4733))
* Fix variable name conflict with component called `<Anchor>` ([#4768](https://github.com/sveltejs/svelte/issues/4768))
## 3.21.0 ## 3.21.0

@ -185,7 +185,7 @@ export default class Block {
this.chunks.mount.push(b`@append(${parent_node}, ${id});`); this.chunks.mount.push(b`@append(${parent_node}, ${id});`);
if (is_head(parent_node) && !no_detach) this.chunks.destroy.push(b`@detach(${id});`); if (is_head(parent_node) && !no_detach) this.chunks.destroy.push(b`@detach(${id});`);
} else { } else {
this.chunks.mount.push(b`@insert(#target, ${id}, anchor);`); this.chunks.mount.push(b`@insert(#target, ${id}, #anchor);`);
if (!no_detach) this.chunks.destroy.push(b`if (detaching) @detach(${id});`); if (!no_detach) this.chunks.destroy.push(b`if (detaching) @detach(${id});`);
} }
} }
@ -295,11 +295,11 @@ export default class Block {
if (this.chunks.mount.length === 0) { if (this.chunks.mount.length === 0) {
properties.mount = noop; properties.mount = noop;
} else if (this.event_listeners.length === 0) { } else if (this.event_listeners.length === 0) {
properties.mount = x`function #mount(#target, anchor) { properties.mount = x`function #mount(#target, #anchor) {
${this.chunks.mount} ${this.chunks.mount}
}`; }`;
} else { } else {
properties.mount = x`function #mount(#target, anchor, #remount) { properties.mount = x`function #mount(#target, #anchor, #remount) {
${this.chunks.mount} ${this.chunks.mount}
}`; }`;
} }

@ -200,7 +200,7 @@ export default class AwaitBlockWrapper extends Wrapper {
} }
const initial_mount_node = parent_node || '#target'; const initial_mount_node = parent_node || '#target';
const anchor_node = parent_node ? 'null' : 'anchor'; const anchor_node = parent_node ? 'null' : '#anchor';
const has_transitions = this.pending.block.has_intro_method || this.pending.block.has_outro_method; const has_transitions = this.pending.block.has_intro_method || this.pending.block.has_outro_method;

@ -219,7 +219,7 @@ export default class EachBlockWrapper extends Wrapper {
} }
`); `);
const initial_anchor_node: Identifier = { type: 'Identifier', name: parent_node ? 'null' : 'anchor' }; const initial_anchor_node: Identifier = { type: 'Identifier', name: parent_node ? 'null' : '#anchor' };
const initial_mount_node: Identifier = parent_node || { type: 'Identifier', name: '#target' }; const initial_mount_node: Identifier = parent_node || { type: 'Identifier', name: '#target' };
const update_anchor_node = needs_anchor const update_anchor_node = needs_anchor
? block.get_unique_name(`${this.var.name}_anchor`) ? block.get_unique_name(`${this.var.name}_anchor`)

@ -320,7 +320,7 @@ export default class ElementWrapper extends Wrapper {
block.chunks.destroy.push(b`@detach(${node});`); block.chunks.destroy.push(b`@detach(${node});`);
} }
} else { } else {
block.chunks.mount.push(b`@insert(#target, ${node}, anchor);`); block.chunks.mount.push(b`@insert(#target, ${node}, #anchor);`);
// TODO we eventually need to consider what happens to elements // TODO we eventually need to consider what happens to elements
// that belong to the same outgroup as an outroing element... // that belong to the same outgroup as an outroing element...

@ -293,7 +293,7 @@ export default class IfBlockWrapper extends Wrapper {
`); `);
const initial_mount_node = parent_node || '#target'; const initial_mount_node = parent_node || '#target';
const anchor_node = parent_node ? 'null' : 'anchor'; const anchor_node = parent_node ? 'null' : '#anchor';
if (if_exists_condition) { if (if_exists_condition) {
block.chunks.mount.push( block.chunks.mount.push(
@ -423,7 +423,7 @@ export default class IfBlockWrapper extends Wrapper {
} }
const initial_mount_node = parent_node || '#target'; const initial_mount_node = parent_node || '#target';
const anchor_node = parent_node ? 'null' : 'anchor'; const anchor_node = parent_node ? 'null' : '#anchor';
block.chunks.mount.push( block.chunks.mount.push(
if_current_block_type_index( if_current_block_type_index(
@ -519,7 +519,7 @@ export default class IfBlockWrapper extends Wrapper {
`); `);
const initial_mount_node = parent_node || '#target'; const initial_mount_node = parent_node || '#target';
const anchor_node = parent_node ? 'null' : 'anchor'; const anchor_node = parent_node ? 'null' : '#anchor';
block.chunks.mount.push( block.chunks.mount.push(
b`if (${name}) ${name}.m(${initial_mount_node}, ${anchor_node});` b`if (${name}) ${name}.m(${initial_mount_node}, ${anchor_node});`

@ -435,7 +435,7 @@ export default class InlineComponentWrapper extends Wrapper {
block.chunks.mount.push(b` block.chunks.mount.push(b`
if (${name}) { if (${name}) {
@mount_component(${name}, ${parent_node || '#target'}, ${parent_node ? 'null' : 'anchor'}); @mount_component(${name}, ${parent_node || '#target'}, ${parent_node ? 'null' : '#anchor'});
} }
`); `);
@ -509,7 +509,7 @@ export default class InlineComponentWrapper extends Wrapper {
} }
block.chunks.mount.push( block.chunks.mount.push(
b`@mount_component(${name}, ${parent_node || '#target'}, ${parent_node ? 'null' : 'anchor'});` b`@mount_component(${name}, ${parent_node || '#target'}, ${parent_node ? 'null' : '#anchor'});`
); );
block.chunks.intro.push(b` block.chunks.intro.push(b`

@ -54,7 +54,7 @@ export default class RawMustacheTagWrapper extends Tag {
const update_anchor = in_head ? 'null' : needs_anchor ? html_anchor : this.next ? this.next.var : 'null'; const update_anchor = in_head ? 'null' : needs_anchor ? html_anchor : this.next ? this.next.var : 'null';
block.chunks.hydrate.push(b`${html_tag} = new @HtmlTag(${init}, ${update_anchor});`); block.chunks.hydrate.push(b`${html_tag} = new @HtmlTag(${init}, ${update_anchor});`);
block.chunks.mount.push(b`${html_tag}.m(${parent_node || '#target'}, ${parent_node ? null : 'anchor'});`); block.chunks.mount.push(b`${html_tag}.m(${parent_node || '#target'}, ${parent_node ? null : '#anchor'});`);
if (needs_anchor) { if (needs_anchor) {
block.add_element(html_anchor, x`@empty()`, x`@empty()`, parent_node); block.add_element(html_anchor, x`@empty()`, x`@empty()`, parent_node);

@ -145,7 +145,7 @@ export default class SlotWrapper extends Wrapper {
block.chunks.mount.push(b` block.chunks.mount.push(b`
if (${slot_or_fallback}) { if (${slot_or_fallback}) {
${slot_or_fallback}.m(${parent_node || '#target'}, ${parent_node ? 'null' : 'anchor'}); ${slot_or_fallback}.m(${parent_node || '#target'}, ${parent_node ? 'null' : '#anchor'});
} }
`); `);

@ -0,0 +1,4 @@
export default {
preserveIdentifiers: true,
html: `<p>Anchor</p>`
};

@ -0,0 +1,5 @@
<script>
import Anchor from './Anchor.svelte';
</script>
<Anchor/>
Loading…
Cancel
Save