use maps instead

pull/6032/head
Tan Li Hau 6 years ago committed by tanhauhau
parent 03f2b15181
commit 36cd61f0c6

@ -904,7 +904,7 @@ The following initialisation options can be provided:
| `target` | **none** | An `HTMLElement` to render to. This option is required | `target` | **none** | An `HTMLElement` to render to. This option is required
| `anchor` | `null` | A child of `target` to render the component immediately before | `anchor` | `null` | A child of `target` to render the component immediately before
| `props` | `{}` | An object of properties to supply to the component | `props` | `{}` | An object of properties to supply to the component
| `context` | `{}` | An object of context to supply to the component | `context` | `new Map()` | A `Map` of context key-value pairs to supply to the component
| `hydrate` | `false` | See below | `hydrate` | `false` | See below
| `intro` | `false` | If `true`, will play transitions on initial render, rather than waiting for subsequent state changes | `intro` | `false` | If `true`, will play transitions on initial render, rather than waiting for subsequent state changes

@ -120,7 +120,7 @@ export function init(component, options, instance, create_fragment, not_equal, p
on_disconnect: [], on_disconnect: [],
before_update: [], before_update: [],
after_update: [], after_update: [],
context: new Map(parent_component ? parent_component.$$.context : options.context ? Object.entries(options.context) : []), context: new Map(parent_component ? parent_component.$$.context : options.context || []),
// everything else // everything else
callbacks: blank_object(), callbacks: blank_object(),

@ -5,10 +5,10 @@ export default {
const called = []; const called = [];
const component = new Component({ const component = new Component({
target, target,
context: { context: new Map([
key: 'svelte', ['key', 'svelte'],
fn: (value) => called.push(value) ['fn', (value) => called.push(value)]
} ])
}); });
assert.htmlEqual(target.innerHTML, '<div>svelte</div><button></button>'); assert.htmlEqual(target.innerHTML, '<div>svelte</div><button></button>');

Loading…
Cancel
Save