- Last 7 days
-
-
Change any of the <option> by double clicking on the number.
-
-
askubuntu.com askubuntu.com
-
You can use Chromium from the Debian buster repository.
-
You can use Chromium from the Debian buster repository. For example, if your Ubuntu release is eoan (19.10):
-
-
forums.theregister.com forums.theregister.com
-
It won't work if $HOME is not under /home. Really. Not even if you softlink. You need a bind mount
-
Why did I put the kdb in the snap file system? Because the app is sandboxed, so I had no choice.
-
- Jan 2021
-
-
I think this is very important feature to implement. Because for now we need to wrap target components by useless wrapper nodes.
-
-
github.com github.com
-
// read-only, but visible to consumers via bind:start export let start = 0;
Can't do
export const start = 0
(because it needs to be mutable/assignable within this local component), so we have to do
export let start = 0
with a comment saying that it's read-only (by the consumer).
-
-
github.com github.com
-
Can't find the Svelte way of doing this, setTimeout helps now, but this is not a good way working with a framework I think.
-
-
svelte.dev svelte.dev
-
https://github.com/sveltejs/svelte/issues/1037#issuecomment-737872461
Explanation (from https://github.com/sveltejs/svelte/issues/1037#issuecomment-739458005):
@AlexGalays register is an action created and passed in from the parent node (Wrapper) which allows the child to register with it. Not builtin to svelte.
That's very clever @PatrickG. Nice one. I was a bit confused when first looking at it to understand what was going on, but I think that will be a handy tool in the toolbox.
But why do we need this? If we remove all use:register, it still toggles just fine. Seems the only benefit is that this allows cleanup.
-
-
stackoverflow.com stackoverflow.com
-
JSONP is really a simply trick to overcome XMLHttpRequest same domain policy. (As you know one cannot send AJAX (XMLHttpRequest) request to a different domain.) So - instead of using XMLHttpRequest we have to use script HTMLl tags, the ones you usually use to load JS files, in order for JS to get data from another domain. Sounds weird?
-
- Dec 2020
-
www.npmjs.com www.npmjs.com
-
Yarn only runs the postinstall hook after yarn and yarn add, but not after yarn remove. The postinstall-postinstall package is used to make sure your postinstall hook gets executed even after a yarn remove.
-
-
-
It seems being able to bind:this={slotEl} directly on a slot element is a popular request. I'll add my +1 as adding div wrappers just to get dom references gets old really fast.
-
-
svelte.dev svelte.dev
-
If you need to pass multiple arguments to an action, combine them into a single object, as in use:longpress={{duration, spiciness}}
-
-
developer.mozilla.org developer.mozilla.org
-
This creates an options object with a getter function for the passive property; the getter sets a flag, passiveSupported, to true if it gets called. That means that if the browser checks the value of the passive property on the options object, passiveSupported will be set to true; otherwise, it will remain false. We then call addEventListener() to set up a fake event handler, specifying those options, so that the options will be checked if the browser recognizes an object as the third parameter.
-
-
thecodebarbarian.com thecodebarbarian.com
-
This pattern can be neater syntactically because declaring a variable in a try block with let scopes the variable to the try block.
-
- Nov 2020
-
-
If I use import { createEventDispatcher } from 'svelte/internal'; instead of import { createEventDispatcher } from 'svelte'; then it seems to work because it's loading from the same module.
-
-
-
So handling the interop upfront will avoid users writing invalid ES6 and make sure that they write ES6 that loads CommonJS in the right way.
-
-
github.com github.com
-
Not being cancelable makes validating dialog content impossible - eg a login dialog or anything that takes user input. Of course, it's easy enough to get around - but I think this should be a requirement of a dialog.
-
-
wresch.github.io wresch.github.io
-
function fail { rm -f ${tmp}* exit 1 } module load bedops || fail
This could be a workaround for my problem where this failed command didn't abort:
set -e { echo 'false'; false; } && { echo 'true'; true; } echo "Got to next line"
Workaround:
set -e { echo 'false'; false; } && { echo 'true'; true; } || exit $? echo "Got to next line"
-
-
stackoverflow.com stackoverflow.com
-
# Run once, hold otherwise if [ -f "already_ran" ]; then echo "Already ran the Entrypoint once. Holding indefinitely for debugging." cat fi touch already_ran
-
Edit this file (corresponding to your stopped container): vi /var/lib/docker/containers/923...4f6/config.json Change the "Path" parameter to point at your new command, e.g. /bin/bash. You may also set the "Args" parameter to pass arguments to the command. Restart the docker service (note this will stop all running containers):
-
-
stackoverflow.com stackoverflow.com
-
{#key} was introduced in Svelte v3.28, before that you needed to use a keyed {#each} block with only one item When the key changes, svelte removes the component and adds a new one, therefor triggering the transition.
-
-
stackoverflow.com stackoverflow.com
-
Thanks so much for the reply! Due to space limitations for comments, I have appended my reply to my original question. Thanks again! (P.S. I can't up-vote your reply until my rep hits 15... Sorry about that.)
-
-
github.com github.com
-
...Then I just make sure that all my $: reactive statements also check whether the values are initialized or not. It's hacky, but it avoids the double render.
-
-
news.ycombinator.com news.ycombinator.com
-
I don't love that you have to re-assign a object/array variable to get Svelte to notice it changed
Tags
Annotators
URL
-
-
-
It won't work in all use cases, but it's better than the div soup.
-
I run into this on almost every project and end up doing this as a workaround: :global([slot="content"]) This allows me to style that extra div in the component that contains the slots but it would be super nice to have <MyComponent slot="content"/> and eliminate that extra div
-
If this is getting implemented, I think I'll love to see both implemented. I can see a lot of use cases where I would like to encapsulate the component with additional wrappers and in another scenarios I would like to just use the component. Now i work around this using empty div but then at times it breaks the structure because of the div element and I'll have to add more class utilities to make it work. This will be a great addition for Svelte.
-
-
dylanvann.com dylanvann.com
-
-
I also tried to use <!-- svelte-ignore unused-export-let --> before the script tag but still no chance.
-
-
github.com github.com
-
You can only adopt a workaround, which can be one of
-
- Oct 2020
-
jhooq.com jhooq.com
-
docs.gitlab.com docs.gitlab.com
-
By using deploy keys, you don’t have to set up a fake user account.
-
-
stackoverflow.com stackoverflow.com
-
I use a mutator and use it's changeValue function to 'change' the value of the relevant field (I supply the same value). This in turn notifies all relevant parties of the change to the form's state, and a validation is triggered.
Nearly duplicate annotation here: https://hyp.is/I2t56hjLEeuPXIsZG-jYog/xtzmf.csb.app/
-
-
xtzmf.csb.app xtzmf.csb.app
-
Use the same value that was submitted, which ensures that a 'change' is triggered even though the value itself doesn't change. Therefore, the same value gets validated again.
Calling it "change" even though it didn't change is kind of cheating/abuse ... but I guess it's okay...??
mutateValue([name], state, { changeValue }) { // change the value to the same value, thus // triggering a revalidation of the same value changeValue(state, name, value => value); }
-
-
github.com github.com
-
But also, if you do want to use separate functions and have your dependencies still counted, you can make all of the relevant dependencies be arguments to those functions, so the compiler can see them in the reactive block.
-
-
github.com github.com
-
if you make a shallow copy, it works
-
this is a common Svelte idiom for manually invalidating something that might have been mutated without there being a visible = sign somewhere
-
-
-
I have a feature spec to test the Javascript behavior of the blur event, sadly Capybara's native DSL doesn't seem to support it yet.
-
-
react-spectrum.adobe.com react-spectrum.adobe.com
-
In addition, this example shows usage of the isPressed value returned by useButton to properly style the button's active state. You could use the CSS :active pseudo class for this, but isPressed properly handles when the user drags their pointer off of the button, along with keyboard support and better touch screen support.
-
-
github.com github.com
-
We aim to support all svelte features. In some cases this is not possible. For those cases we provided feasible workarounds.
-
jsx currently does not allow to use : in attribute/property names. As a workaround every : can be replaced be _ (for example bind_value is converted to bind:value for svelte).
-
-
www.python.org www.python.org
-
The limits are chosen to avoid wrapping in editors with the window width set to 80, even if the tool places a marker glyph in the final column when wrapping lines.
-
-
stackoverflow.com stackoverflow.com
-
I need this as a workaround for CSS Regions which currently don't dispatch child node events. Regions only render the child node content, they don't act as parentNodes.
-
-
-
A reasonably clean alternative would be to map a function over the array and use destructuring in the each loop: {#each [1, 2, 3, 4].map(n => ({ n, sqr_n: n * n })) as { n, sqr_n }} {sqr_n} {sqr_n / 2}<br> {/each}
-
Similar to Javascript or ocaml it is always possible to replace let with a new function, so as you say there are ways around the lack of syntax.
-
-
github.com github.com
-
I discovered that a solution can be hacked using an {#if}, but a proper one would be nice:
-
-
tech.ebayinc.com tech.ebayinc.com
-
Offsetting the rules of a logic-less template requires a lot of helper methods.
-
-
-
I had this problem and figured out how to make something like this work with the compiler quirks.
-
Here's a proxy store I wrote to derive the value of a store nested within other stores, it plays nice with typescript and can go infinitely deep
-
Proposed workarounds get particularly awkward for multiple stores
good example follows
Tags
- don't just complain; help improve/fix things
- clever
- Svelte: store
- proxy (programming)
- Svelte: store: derived
- wrapper
- good example
- arbitrary limitations leading to less-than-ideal workarounds
- elegant solution
- missing feature leading to less-than-ideal workarounds
- build your own
- workarounds
- awkward workarounds
Annotators
URL
-
-
github.com github.com
-
This reactive statement is just used to have the store automatically subscribed and unsubscribed.
-
-
dylanvann.com dylanvann.com
-
the code is a bit verbose/convoluted
-
-
dylanvann.com dylanvann.com
-
Using another reactive statement with $effect we have Svelte automatically handle subscribing and unsubscribing to the store
-
-
github.com github.com
-
React hook for creating a value exactly once. useMemo doesn't give this guarantee unfortunately - https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
-
-
-
If you are wondering about the odd looking (d), this keys the component, ensuring that the compiler doesn’t do any fancy sharing of objects that leads to surprising bugs. You don’t often need to key items in Svelte, but I have run into some cases where it is essential.
Tags
Annotators
URL
-
- Sep 2020
-
github.com github.com
-
Since this issue seems to pop up periodically, it would be useful to turn this into a warning. It may not be elegant, but it prevents surprise blank screens due to a navigation error.
Not an actual fix.
-
-
github.com github.com
-
setClient(writable(apolloClient)); let client getClient().subscribe((_client) => client = _client);
-
-
-
github.com github.com
-
Instead, I threw together some javascript you can put in a js-file and run postinstall with node. "postinstall": "node clean-svelte.js"
-
-
stackoverflow.com stackoverflow.com
-
setContext / getContext can only be used once at component init, so how do you share your API result through context? Related: how would you share those API results if the call was made outside of a Svelte component, where setContext would be even more out of the question (and the API call would arguably be better located, for separation of concerns matters)? Well, put a store in your context.
-
-
github.com github.com
-
To be clear, I have a reasonable workaround. I'd only like it to be less difficult to discover. At a minimum, this issue should help others find it...
-
-
-
I guess we could always add a bunch of adapter code to watch the flag and trigger a callback when it becomes true or false...
-
-
svelte.dev svelte.dev
-
-
You can then ensure that only one instance of angular is loaded from your main module by adding an alias
-
-
medium.com medium.com
-
Modules using code that doesn’t exist in browsers such as process.env.NODE_ENV and forcing you to convert or polyfill it.
-
Personally for me, this is incredibly hard to read. Regex everywhere, nested objects with different rules and configurations that are very intuitive, multiple loaders that resolve backwards, built in loaders having obscure issues that require using third party loaders in between, separation of plugins and loaders, and so on.
-
-
engineering.mixmax.com engineering.mixmax.com
-
Rollup is a tool that lets you write your application using ES6 modules, even though you can't publish those modules directly to your users, because native support is only just starting to land in browsers. Rollup compiles your modules into a format that all browsers _do_ understand—a single script file—by, essentially, concatenating files together (while reordering and renaming declarations to preserve scope).
-
-
github.com github.com
-
I don't understand why it just launches the mutation once and then it throws the error Function called outside component initialization, the only way to make it work is to do something like $: result = mutation(...) but it doesn't make sense, I don't want to run the mutation after each keystroke.
-
-
stackoverflow.com stackoverflow.com
-
The recommended solution for onMount is the same as for useEffect — place an async function inside the handler
-
onMount(() => { async function foo() { bar = await baz(); } foo();
-
-
-
Currently, I can only do this with some ugly JS, by wrapping the <slot> in a div and then selecting all direct children of that div (div>*). But this fix/solution also makes me face a problem: The <div> partially destroys the layout/design compared to when not using that div wrapper.
-
There are work arounds, but nothing clean. I just feel like this should be functionality that should be part of the slot feature.
-
-
github.com github.com
-
Svelte will not offer a generic way to support style customizing via contextual class overrides (as we'd do it in plain HTML). Instead we'll invent something new that is entirely different. If a child component is provided and does not anticipate some contextual usage scenario (style wise) you'd need to copy it or hack around that via :global hacks.
Tags
- forced to fork/copy and paste library code because it didn't provide enough customizability/extensibility / didn't foresee some specific prop/behavior that needed to be overridable/configurable (explicit interface)
- forking to add a desired missing feature/change
- trying to prevent one bad thing leading to people doing/choosing an even worse option
- maintenance burden to explicitly define/enumerate/hard-code possible options (explicit interface)
- run-time dynamicness/generics vs. having to explicitly list/hard-code all options ahead of time
- Svelte: how to affect child component styles
- ugly/kludgey
- component/library author can't consider/know ahead of time all of the ways users may want to use it
- workarounds
Annotators
URL
-
-
github.com github.com
-
The problem with working around the current limitations of Svelte style (:global, svelte:head, external styles or various wild card selectors) is that the API is uglier, bigger, harder to explain AND it loses one of the best features of Svelte IMO - contextual style encapsulation. I can understand that CSS classes are a bit uncontrollable, but this type of blocking will just push developers to work around it and create worse solutions.
Tags
- +0.9
- trying to prevent one bad thing leading to people doing/choosing an even worse option
- key point
- important point
- arbitrary limitations leading to less-than-ideal workarounds
- missing out on the benefits of something
- Svelte: CSS encapsulation
- Svelte: how to affect child component styles
Annotators
URL
-
-
github.com github.com
-
Would style .classInChild from your parent. The only drawback is that you might need an extra wrapping element.
-
-
github.com github.com
-
For my simple tooltip example, I could create a TooltipHitbox component with a <slot/> inside a <div use:myTooltip={tooltipProp}> and then wrap MatButton instances with that component.
-
-
github.com github.com
-
Also, I'm starting to wonder if maybe it's okay to have multiple spreads? If the alternative to <Foo {...a} {...b} {...c} d={42}> is that people will write <Foo {...Object.assign({}, a, b, c)} d={42}> anyway, then do we gain anything with the constraint?
-
-
-
Not sure if there is a better way, but I declare all possible component constructors and then use that map to convert string component names found in JSON to Components.
Tags
Annotators
URL
-
-
-
Is there a good way to do this given the compiler won't know at build time what events are needed? Should I make a wrapper that does addEventListener myself with a bind:this? Would be nice if Svelte could handle dynamic events though.
-
-
final-form.org final-form.org
-
By default, in order to allow inline fat-arrow validation functions, the field will not rerender if you change your validation function to an alternate function that has a different behavior. If you need your field to rerender with a new validation function, you will need to update another prop on the Field, such as key
-
-
stackoverflow.com stackoverflow.com
-
props does not update in real time. You can try console.log(values.firstName) inside the validate function to confirm this. To get around this my way is quite a hack, just add key = {values.firstName} to Field component like this
-
-
-
I don't know what is the status of <svelte:body class:name={condition} implementation, but in the meantime, I've managed to overpass this issue by using <svelte:head> instead. As my need was to add styling to my page's body.
Tags
Annotators
URL
-
-
www.coreycleary.me www.coreycleary.me
-
here I wrapped the function call in an IIFE - that's what that (async () => {....})() is if you've never seen it. This is simply because we need to wrap the await call in a function that uses the async keyword, and we also want to "immediately invoke" the function (IIFE = "Immediately Invoked Function Execution") in order to call it.
-
-
developer.mozilla.org developer.mozilla.org
-
Here we store the three Promise objects in variables, which has the effect of setting off their associated processes all running simultaneously. Next, we await their results — because the promises all started processing at essentially the same time, the promises will all fulfill at the same time
-
-
github.com github.com
-
Using a reactive statement is a good way to explicitly turn a reactive variable into a store
-
-
github.com github.com
-
{#each section as {tag, is_self_closing, props, content}} {#if is_self_closing} <{tag} {...props} /> {:else} <{tag} {...props}>{content}</{tag}> {/if}
-
-
github.com github.com
-
Even without going to that extreme, the constraint of having a single <style> can easily force component authors to resort to the kinds of classes-as-namespaces hacks that scoped styles are supposed to obviate.
-
-
github.com github.com
-
but that feels like a hack
-
-
svelte.dev svelte.dev
-
export { className as class }
Tags
Annotators
URL
-
-
github.com github.com
-
:global just feels like a hack for a feature that should already be there.
-
-
-
<button class="some-class {$$props.class}">
-
-
medium.com medium.com
-
Svelte offers an immutable way — but it’s just a mask to hide “assignment”, because assignment triggers an update, but not immutability. So it’s enough to write todos=todos, after that Svelte triggers an update.
-
-
css-tricks.com css-tricks.com
-
style="--columns:{cols}"
-
-
github.com github.com
-
Some Svelte component's allow you to bind to internal data which doesn't make too much sense outside of Svelte yet they often form an important part of the API. Instead I have added the option to use a watch* prop (similar to the on* prop). This also takes a callback function and recieves the value you wish to watch as its only argument. watchNumber={ n => setCount(n) } would watch the internal value number, when number changes the callback you passed to it would be executed receiving the new number value as its only argument. This may seem strange but many Svelte components are written to make use of this bind syntax, without it there is often a hole in the API leaving you unable to respond to internal state changes. You will probably want to control your state with React, this watch* prop is an escape hatch that allows you to pull out those internal values to use however you wish.
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
I took the liberty of editing this answer because it's already accepted
-
-
svelte.dev svelte.dev
-
In mapbox.js you'll see this line: const key = {};We can use anything as a key — we could do setContext('mapbox', ...) for example. The downside of using a string is that different component libraries might accidentally use the same one; using an object literal means the keys are guaranteed not to conflict in any circumstance (since an object only has referential equality to itself, i.e. {} !== {} whereas "x" === "x"), even when you have multiple different contexts operating across many component layers.
-
-
stackoverflow.com stackoverflow.com
-
github.com github.com
-
Force everything to the git root per NPM lameness
-
For a non-monorepo package you can simply point directly to the Github repo. This case is similar, but you want to scope it just to a single package within the repo. For those that make monorepos they don't necessarily need this feature. It's for those that use projects that use monorepos. Telling them to not organize their projects into monorepos doesn't help people who make use of these projects.
-
npm's inability to handle monorepos then i'd have designed my repos accordingly
-
-
-
Between each step I did rm -rf node_modules package-lock.json && npm i. Just to be sure
-
- Aug 2020
-
github.com github.com
-
I could add .json on the end, but that would mean hacking away at angularjs, which is doing the right thing. I would rather find a good solution and hack away at rails, which is doing the wrong thing :)
-
In that case I would suggest to use .xml or .json format to eliminate accept header parsing issue.
Avoid using a perfectly good feature (accept header negotiation) just because browsers screwed things up?
-
Safari sends following order application/xml (q is 1) application/xhtml+xml (q is 1) image/png (q is 1) text/html (q is 0.9) text/plain (q is 0.8) \*/\* (q is 0.5) So you visit www.myappp.com in safari and if the app supports .xml then Rails should render .xml file. This is not what user wants to see. User wants to see .html page not .xml page.
-
- Jul 2020
-
api.rubyonrails.org api.rubyonrails.org
-
Note: Acronyms that are passed to pluralize will no longer be recognized, since the acronym will not occur as a delimited unit in the pluralized result. To work around this, you must specify the pluralized form as an acronym as well:
-
-
support.iubenda.com support.iubenda.com
-
rails.lighthouseapp.com rails.lighthouseapp.com
-
Just ran into this problem myself and will work around it less elegantly for now.
-
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
This works as expected (using r for making it an exact Rational): p Time.utc(2007, 11, 1, 15, 25, 0, 123456.789r) # => 2007-11-01 15:25:00.123456789 UTC
Tags
Annotators
URL
-
-
blog.toshima.ru blog.toshima.ru
-
To stop emitting the warnings, just add RUBYOPT=-W:no-deprecated.
-
-
code-examples.net code-examples.net
-
JSON parsing is always pain in ass. If the input is not as expected it throws an error and crashes what you are doing. You can use the following tiny function to safely parse your input. It always turns an object even if the input is not valid or is already an object which is better for most cases.
It would be nicer if the parse method provided an option to do it safely and always fall back to returning an object instead of raising exception if it couldn't parse the input.
-
-
stackoverflow.com stackoverflow.com
-
Creating and calling a default proc is a waste of time, and Cramming everything into one line using tortured constructs doesn't make the code more efficient--it just makes the code harder to understand.
The nature of this "answer" is a comment in response to another answer. But because of the limitations SO puts on comments (very short length, no multi-line code snippets), comment feature could not actually be used, so this user resorted to "abusing" answer feature to post their comment instead.
See
-
- Jun 2020
-
stackoverflow.com stackoverflow.com
-
makandracards.com makandracards.com
-
However, a ActiveRecord::Rollback within the nested transaction will be caught by the block of the nested transaction, but will be ignored by the outer transaction, and not cause a roll back! To avoid this unexpected behaviour, you have to explicitly tell rails for each transaction to indeed use proper nesting: CopyActiveRecord::Base.transaction(joinable: false, requires_new: true) do # inner code end This is a safer default for working with custom transactions.
-
-
api.rubyonrails.org api.rubyonrails.org
-
This is a poor solution
What's so bad about this solution? If it works, it works. And it only requires wrapping in 1 additional block. Pretty simple.
-
One workaround is to begin a transaction on each class whose models you alter:
-
- May 2020
-
stackoverflow.com stackoverflow.com
-
Note that this will pull the container if it exists. Pulling even the small alpine is quite an overhead just to get that information. Not mentioning the several GB-Image one often has in CI-Environments.
-
-
stackoverflow.com stackoverflow.com
-
'
because it's in YAML
but this means you can't use any ' in the actual script line
or you have to use different delimiters if you do
bottom line is it makes it harder to write/include your script than simply creating a separate shell script file.
-
-
csp.withgoogle.com csp.withgoogle.com
-
However, it's possible to enforce both a whitelist and nonces with 'strict-dynamic' by setting two policies:
-
-
iandunn.name iandunn.name
-
I just noticed that git svn clone has an optional --log-window-size parameter, though, and it lets you determine how many log entries are scanned at a time. The default is 100, but if you bump it up to 5000, then it only takes a few minutes to clone the plugin, making git-svn a viable option.
-