Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct replacements of css.<key> values #436

Merged
merged 4 commits into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/svelte/src/markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ function updateCss({ content, result }) {
code : content
// Replace simple {css.<key>} values first
.replace(
new RegExp(`{css.(${Object.keys(exported).join("|")})}`, "gm"),
new RegExp(`{css\\.(${Object.keys(exported).join("|")})}`, "gm"),
(match, key) => exported[key].join(" ")
)
// Then any remaining bare css.<key> values
.replace(
new RegExp(`(\\b)css.(${Object.keys(exported).join("|")})(\\b)`, "gm"),
new RegExp(`(\\b)css\\.(${Object.keys(exported).join("|")})(\\b)`, "gm"),
(match, prefix, key, suffix) => `${prefix}"${exported[key].join(" ")}"${suffix}`
)
};
Expand Down
63 changes: 0 additions & 63 deletions packages/svelte/src/methods.js

This file was deleted.

10 changes: 9 additions & 1 deletion packages/svelte/test/__snapshots__/svelte.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ exports[`/svelte.js should extract CSS from a <link> tag (existing script) 1`] =
export default {
data : () => ({
bool : true
})
}),

oncreate() {
const bd = {
flex : \\"flex\\"
};

const style = css[bd.flex];
}
};</script>
"
`;
Expand Down
10 changes: 9 additions & 1 deletion packages/svelte/test/specimens/external-script.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ <h1 class="{css.hd}">Head</h1>
export default {
data : () => ({
bool : true
})
}),

oncreate() {
const bd = {
flex : "flex"
};

const style = css[bd.flex];
}
};
</script>