fix dynamic title bug

pull/1839/head
Rich Harris 7 years ago
parent 1d2197a589
commit 951cbcd585

@ -4,6 +4,7 @@ import Block from '../Block';
import Title from '../../nodes/Title';
import FragmentWrapper from './Fragment';
import { stringify } from '../../../utils/stringify';
import addToSet from '../../../utils/addToSet';
export default class TitleWrapper extends Wrapper {
node: Title;
@ -32,12 +33,8 @@ export default class TitleWrapper extends Wrapper {
if (this.node.children.length === 1) {
// single {tag} — may be a non-string
const { expression } = this.node.children[0];
const { dependencies, snippet } = this.node.children[0].expression;
value = snippet;
dependencies.forEach(d => {
allDependencies.add(d);
});
value = expression.render();
addToSet(allDependencies, expression.dynamic_dependencies);
} else {
// '{foo} {bar}' — treat as string concatenation
value =

@ -0,0 +1,12 @@
export default {
props: {
foo: 'A Title'
},
test({ assert, component, target, window }) {
assert.equal(window.document.title, 'A Title');
component.foo = 'Also A Title';
assert.equal(window.document.title, 'Also A Title');
}
};

@ -0,0 +1,3 @@
<svelte:head>
<title>{foo}</title>
</svelte:head>

@ -1,7 +1,7 @@
import * as assert from 'assert';
import { readable, writable, derive } from '../../store.js';
describe.only('store', () => {
describe('store', () => {
describe('writable', () => {
it('creates a writable store', () => {
const count = writable(0);

Loading…
Cancel
Save