- Sep 2024
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
Here's example code which works around the lack of a ??= operator in the wild:
-
-
github.com github.com
-
However, this idiom is only an approximation, and introduces subtle bugs when we try to allow false values:
-
- Aug 2024
-
github.com github.com
-
However, in order to tell InheritedResources that it really failed, you need to add errors to your model.
-
- Jul 2024
-
stackoverflow.com stackoverflow.com
-
I've just experienced the same issue with confirmation links being executed in a sent email before the user has received them and invalidating the link. I got around the issue by modifying the page the URL links to. I've added a Confirm button on the page which the user has to click to confirm their email and this works nicely.
-
-
www.drupal.org www.drupal.org
-
Especially users working with Microsoft Office 365 and therefore Outlook noticed very often that login is not possible. Upon closer analysis, it was found that the MS/Bing crawlers are particularly persistent and repeatedly call the reset links, regardless of server configuration or the like. For this reason, a text field was implemented in the backend via the Drupal State API, in which selected user agents (always one per line) can be entered. These are checked by 'Shy One Time', in case of a hit a redirect to the LogIn form with a 302 status code occurs, the reset link is not invalidated.
-
-
wordtothewise.com wordtothewise.com
-
Another suggestion some senders are trying is to set up a “stealth” link, that human readers won’t see or click on but that parsing software might. Clicks on that link are a sign that the click was not done by the recipient.
-
- Feb 2024
-
meta.stackoverflow.com meta.stackoverflow.com
-
As you've seen, there is no DM system, but you can invite users to chat directly. More generally, consider commenting on the question itself and @-ing the user who made the edit(s). To my understanding, this should work, and it may allow for a quick explanation that doesn't require going in to chat.
I think commenting in the context of question is better than a DM, though I don't always like making my question "messy" by having a bunch of comments under it... but maybe that is the best way.
-
- Jan 2024
-
www.ruby-forum.com www.ruby-forum.com
-
One way to potentially get around this is to have an object that simple holds a class and overrides the === operator to make case work properly:
-
-
mattbrictson.com mattbrictson.com
-
Some frameworks call this “template inheritance”. In this example, we might say that the application layout “inherits from” or “extends” the base layout. In Rails, this is known as nested layouts, and it is a bit awkward to use. The standard Rails practice for nested layouts is complicated and involves these considerations
-
But what if you want to reuse one layout within another?
-
-
-
It can sort of be achieved with the current setup (via labels), but I really like where this is going -- turning everything into a similar "object" in a hierarchy rather than separate standalone structures that connect and get "labeled" to show what they are.
-
- Dec 2023
-
gitlab.com gitlab.com
-
Enable ActiveRecord unsigned integers to use 8 bytes instead of 4. This fixes the ActiveModel::RangeError problem where AR models with perfectly fine 8 bytes primary keys are taken for ActiveModel::Type::Integer with a default limit of 4 bytes.
-
- Nov 2023
-
www.appsloveworld.com www.appsloveworld.com
-
In development, I was able to reset the exponential cool down by removing the g_state cookie. One method for this might be to add a development-only "Clear Google One Tap Cookie" link that run an server-side action to remove the g_state cookie and then redirect back to the previous page.
-
- Sep 2023
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
sums = [0] (1..gains.length).each do |i| sums[i] = sums[i - 1] + gains[i - 1] end could, if scan was introduced, be replaced with: sums = gains.scan_left(0, &:+)
-
- Aug 2023
-
www.ruby-forum.com www.ruby-forum.com
-
I ran into the same problem and never really found a good answer via the test objects. The only solution I saw was to actually update the session via a controller. I defined a new action in one of my controllers from within test_helper (so the action does not exist when actually runnning the application). I also had to create an entry in routes. Maybe there’s a better way to update routes while testing. So from my integration test I can do the following and verfiy: assert(session[:fake].nil?, “starts empty”) v = ‘Yuck’ get ‘/user_session’, :fake => v assert_equal(v, session[:fake], “value was set”)
-
-
stackoverflow.com stackoverflow.com
-
I make a file named: app/models/active_storage/attachment.rb. Because it's in your project it takes loading precedence over the Gem version. Then inside we load the Gem version, and then monkeypatch it using class_eval: active_storage_gem_path = Gem::Specification.find_by_name('activestorage').gem_dir require "#{active_storage_gem_path}/app/models/active_storage/attachment" ActiveStorage::Attachment.class_eval do acts_as_taggable on: :tags end The slightly nasty part is locating the original file, since we can't find it normally because our new file takes precedence. This is not necessary in production, so you could put a if Rails.env.production? around it if you like I think.
-
- Jun 2023
-
stackoverflow.com stackoverflow.com
-
As far as I see the current version of arel gem is not support FROM keyword for the sql query. You can generate a query using the SET, and WHERE keywords only,
-
-
stackoverflow.com stackoverflow.com
-
What I have seen is situations where things were made horribly complicated to get around protections for which there was no need, and to try to guard the consistency of data structures that were horribly over-complicated and un-normalized.
-
-
stackoverflow.com stackoverflow.com
-
Have you ever: Been disappointed, surprised or hurt by a library etc. that had a bug that could have been fixed with inheritance and few lines of code, but due to private / final methods and classes were forced to wait for an official patch that might never come? I have. Wanted to use a library for a slightly different use case than was imagined by the authors but were unable to do so because of private / final methods and classes? I have.
-
- Mar 2023
-
stackoverflow.com stackoverflow.com
- Feb 2023
-
medium.com medium.com
-
Developers are faced with two realistic choices. First, they can give up, and work around the API issue (this happens more often than we would like to admit).
-
- Jan 2023
-
kmitov.com kmitov.com
-
You can workaround this with material.translations.with_deleted.where(locale: I18n.locale).first.title But this is quite ugly.
-
- Dec 2022
-
stackoverflow.com stackoverflow.com
-
Procs can't accept blocks as implicit arguments (the format you're trying). A proc can receive other proc objects as arguments, either explicitly, or using & arguments. Example: a = Proc.new do |&block| block.call end a.call() {puts "hi"}
-
- Nov 2022
-
github.com github.com
-
The thing is Chrome doesn't provide details about such resources.
-
-
www.suffix.be www.suffix.be
-
So far for the obligatory warning. I get the point, I even agree with the argument, but I still want to send a POST request. Maybe you are testing an API without a user interface or you are writing router tests? Is it really impossible to simulate a POST request with Capybara? Nah, of course not!
-
-
gitlab.com gitlab.com
-
Good commit hygiene is considered a best practice. GitLab should encourage and enable these kinds of best practices. This feature currently creates a problem and requires workarounds that remove information, or significant manual work.
-
-
github.com github.com
-
www.markusdosch.com www.markusdosch.com
-
nickjanetakis.com nickjanetakis.com
-
Lucky for us, it’s super easy to use subdomains in development nowadays. http://lvh.me is a free service that resolves itself along with all subdomains to localhost.
-
-
stackoverflow.com stackoverflow.com
-
If you're nested inside several blocks and can't use next, rather extract the contents of the transaction into its own method and use return there.
-
-
github.com github.com
-
Can you refactor your code so that instead of returning from within the transaction block you set a variable and then return outside of the block?
-
- Oct 2022
-
-
Note that one extra type that is accepted by convention is the Boolean type, which represents both the TrueClass and FalseClass types.
-
-
apple.stackexchange.com apple.stackexchange.com
-
This is great because it works in Terminal, iTerm2, Chrome, Sublime & Outlook. The alternative (Karabina) is less good because that maps "Home" to Command+LeftArrow, which actually switches windows in Terminal.
-
-
stackoverflow.com stackoverflow.com
-
what fixed my issue was: remove the node-sass from package.json npm install install it again in latest version via npm install --save-dev node-sass if you find this helpful, I assume you just need to upgrade your node-sass for the latest version because it uses node-gyp as a lower version.
-
-
github.com github.com
-
var a = document.createElement("a"); a.href = blob; a.target = "_blank"; setTimeout(function() { click(a); });
-
- Sep 2022
-
-
I ended up using a really poor hack, in my package.json, scripts: { ... "prebundle": "openapi bundle -o src/openapi.preprocessed.json spec/openapi.yaml --force --config .redocly.pre-processor.yaml 2>/dev/null && echo 'warning: errors from pre-processing step have been supressed'", "bundle": "openapi bundle -o src/openapi.json src/openapi.preprocessed.json ... }
-
- Apr 2022
-
css-tricks.com css-tricks.com
-
There are ways to create aspect-ratio sized boxes in HTML/CSS today. None of the options are particularly elegant because they rely on the “hack” of setting a zero height and pushing the boxes height with padding. Wouldn’t it be nicer to have a platform feature to help us here?
-
- Mar 2022
-
askubuntu.com askubuntu.com
-
I realize this isn't an ideal solution - but seems to be the truth to the issue. The only relevant solution I could muster is actually a hack, create a script that executes an infinite while loop that just replaces the Primary Selection with a null value.
-
- Jan 2022
-
github.com github.com
-
If this proposal is fully implemented, we will end up with this garbage everywhere.
-
-
github.com github.com
-
// Prevent errors crashing Node.js, see: // https://github.com/nodejs/node/issues/20392 this.promise.catch(() => {})
-
- Nov 2021
-
-
Yep, we experimented with this, but what we found is that you loose most of Svelte's niceness like slots, and instead you'll pass around deeply nested objects.
-
-
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}}
-
- Oct 2021
-
github.com github.com
-
while with server/externalFetch there is no direct way to pass cookie headers from the original request to the external one
-
Right now I am working around this issue by having an internal [...api].js, then call fetch for that endpoint (which automatically passes on cookies) and from there hit the actual external endpoint. It works, there is no risk of leaking anything, but imo shouldn't be necessary.
-
I am currently circumventing this issue by using getSession to have access to the cookies/headers in the load method
We did something similar for a while...
-
- Aug 2021
-
github.com github.com
-
Using min-width to set the width of the iFrame, works around an issue in iOS that can prevent the iFrame from sizing correctly.
-
-
destroytoday.com destroytoday.com
-
With JavaScript, you can actually calculate the width of the scrollbar and whether it’s visible by comparing two properties—window.innerWidth and document.body.clientWidth. If these are equal, the scrollbar isn’t visible. If these are different, we can subtract the body width from the window width to get the width of the scrollbar:const scrollbarWidth = window.innerWidth - document.body.clientWidthWe’ll want to perform this both on page load and on resize, in case someone resizes the window vertically and changes the overflow. Then, once we have the scrollbar width, we can assign it as a CSS variable:document.body.setProperty("--scrollbarWidth", `${scrollbarWidth}px`)
missing feature: vw/vh can't be used "directly" because doesn't account for scrollbars
-
-
github.com github.com
-
You can add event modifiers with the on:click$preventDefault$capture={handler} syntax. If you use Svelte's native on:click|preventDefault={handler} syntax, it will not compile. You have to use "$" instead of "|". (The extra S inside the | stands for SMUI.)
How does it do that? I didn't think components could introspect to see which event handlers were added by the calling component?!
Does it actually somehow generate an event named something like
click$preventDefault$capture
? I still don't get how that would work.
-
- Jul 2021
-
direnv.net direnv.net
-
direnv is not loading the .envrc into the current shell. It’s creating a new bash sub-process to load the stdlib, direnvrc and .envrc, and only exports the environment diff back to the original shell. This allows direnv to record the environment changes accurately and also work with all sorts of shells. It also means that aliases and functions are not exportable right now.
-
-
stackoverflow.com stackoverflow.com
-
I think that it's nonsense not to have a method that just gives -1 or +1. Even BASIC has such a function SGN(n). Why should we have to deal with Strings when it's numbers we want to work with. But's that's just MHO.
-
- May 2021
-
github.com github.com
-
fetch: fetcher
Personally, I don't like how the local/custom/wrapper version of
fetch
is calledfetcher
. I feel like{prefix}_fetch
orfetch_{prefix}
would have been better.
-
- Apr 2021
-
store.steampowered.com store.steampowered.com
-
First, no joypad support. It's not a big deal because you can still use big picture emulation or joy2key
-
-
stackoverflow.com stackoverflow.com
-
Too new to comment on the specific answer
So you think it's better to make people post a new "answer" (as if it were actually a distinct, unrelated answer) instead of just letting them comment on the answer that they actually want to comment on? Yuck.
-
-
trevershick.github.io trevershick.github.io
-
After some searching i found a stack overflow problem that didn't fix my issue but anyhow… I simply used a little ruby and the capybara library to find the field myself with some case insensitive regex and the ruby detect method
-
-
github.com github.com
-
For now, you will need to give the second root a different named route: authenticated :user do root to: "users#index", as: :authenticated_root end unauthenticated do root to: "main#index" end
-
- Mar 2021
-
www.jackfranklin.co.uk www.jackfranklin.co.uk
-
If I were to sum up why in one sentence, it's because I don't miss useEffect. I understand why it exists, I understand the approach React takes, and there are benefits of its approach. But writing complex React components feels more like admin; a constant worry that I'll miss a dependency in my useEffect call and end up crashing my browser session. With Svelte I don't have that lingering feeling, and that's what I've come to enjoy.
-
One gripe I've had with this approach is that you lose the visual cues that you're passing children into the Box component; they now aren't nested within the Box when you render them like we're used to in HTML; it's now up to you to read the props and spot which ones are being used to provide children.
-
Here's where I start to have a preference for Svelte; the two are very similar but once I got used to Svelte I found that React felt like jumping through hoops. You can't create a worker instance, it has to go in a useRef, and then you can't easily pull code out into a function without then requiring useCallback so it can be a safe dependency on useEffect. With Svelte I write code that's closer to "plain" JavaScript, whereas in React more of my code is wrapped in a React primitive.
-
because React components are re-executed every time the component re-renders, you can easily end up with thousands of workers being created! It's essential to use useRef to avoid this problem by maintaining a reference to the worker that you've created.
-
-
unix.stackexchange.com unix.stackexchange.com
-
If you really want this, I suggest you write a little function that extracts the executable name from the .desktop file and runs it. Add these lines to your shell's initialization file (e.g. ~/.bashrc): runDesktop () { eval "$(awk -F= '$1=="Exec"{$1=""; print}' "$1")" } Then, you can run your .desktop file with runDesktop ~/Desktop/slack.desktop
-
-
unix.stackexchange.com unix.stackexchange.com
-
A solution is almost indicated in the question: hinder xdg-open from choosing exo-open. A brute-force approach is to copy /usr/bin/xdg-open to /usr/local/bin (/usr/local/bin is earlier in PATH unless PATH has been modified) and to patch it to use open_generic instead of exo_open (unlike the XFCE4-specific exo-open, open_generic does honor xdg mime types)
-
-
askubuntu.com askubuntu.com
-
neither knows what to do with naked domain. So gnome-open http://askubuntu.com works but not gnome-open askubuntu.com. Here is a small function to make it easier to type and accept the stripped down domain name. function go { gnome-open http://$1 ; }
-
-
store.steampowered.com store.steampowered.com
-
Works also on Linux if you install Steam for Windows on Wine.
-
-
github.com github.comd3/d31
-
To the consternation of some users, 3.x employed Unicode variable names such as λ, φ, τ and π for a concise representation of mathematical operations. A downside of this approach was that a SyntaxError would occur if you loaded the non-minified D3 using ISO-8859-1 instead of UTF-8. 3.x also used Unicode string literals, such as the SI-prefix µ for 1e-6. 4.0 uses only ASCII variable names and ASCII string literals (see rollup-plugin-ascii), avoiding encoding problems.
-
-
github.com github.com
-
I've been able to find three alternatives ahead of the bugfix
-
-
stackoverflow.com stackoverflow.com
-
You can use the :placeholder-shown pseudo class. Technically a placeholder is required, but you can use a space instead.
-
There is (currently) no CSS selector for detecting directly whether an input control has a nonempty value, so we need to do it indirectly, as described above.
-
-
css-tricks.com css-tricks.com
-
:placeholder-shown is super useful for us here! It’s basically the secret selector for testing if an input currently has a value or not.
-
-
-
Dave Rupert has a good solution that uses an input's invalid event. Instead of using the :invalid pseudo selector, he adds a CSS class to the input when it becomes invalid. We will extend this approach by removing the CSS class when the element becomes valid again.
-
-
www.html5rocks.com www.html5rocks.com
-
Validating forms has notoriously been a painful development experience. Implementing client side validation in a user friendly, developer friendly, and accessible way is hard. Before HTML5 there was no means of implementing validation natively; therefore, developers have resorted to a variety of JavaScript based solutions.
-
-
trailblazer.to trailblazer.to
-
You need to create a copy of the method or the class of your callable task in order to fix this and have two identical steps.
-
- Feb 2021
-
stackoverflow.com stackoverflow.com
-
# catch multi-char special key sequences read -sN1 -t 0.0001 k1 read -sN1 -t 0.0001 k2 read -sN1 -t 0.0001 k3 key+=${k1}${k2}${k3}
-
-
github.com github.com
-
For now I've worked around this by putting all the key-value pairs into an array before passing them into the interaction, then re-building the hash inside the interaction. It works, but it requires some extra code
-
You can use it by allowing a hash with arbitrary keys, but that loses type-safety one that object.
-
Thanks, I'll continue leaning on the array workaround for my use case then.
-
-
github.com github.com
-
I had to use something like this: occupancy.errors.messages.each do |column, messages| messages.each { |m| errors.add(column, m) } end
-
-
railscasts.com railscasts.com
-
So how are we going to create a model that doesn’t have a database table behind it? There are several potential solutions including various plugins but we’re going to use the method described in an entry on the Code Tunes blog. This shows a techinque that involves overriding a couple of methods in an ActiveRecord model and then manually defining the columns in the model file rather than in the database table. In our Recommendation model we’ll add in the two overridden methods and then use the column class method to define the columns in a similar way to how they’re defined in a migration file.
Does this still work in Rails 6? I wonder.
-
-
en.wikipedia.org en.wikipedia.org
-
With the introduction of CPUs which ran faster than the original 4.77 MHz Intel 8088 used in the IBM Personal Computer, programs which relied on the CPU's frequency for timing were executing faster than intended. Games in particular were often rendered unplayable. To provide some compatibility, the "turbo" button was added. Engaging turbo mode slows the system down to a state compatible with original 8086/8088 chips.
-
-
coderwall.com coderwall.com
-
There is nothing wrong with accepts_nested_attributes_for. This is what you should use in your typical case. My post describes a non-typical case. ContactListForm is not an ActiveRecord object, it is an object that includes ActiveModel::Model, which does not support accepts_nested_attributes_for.
-
-
github.com github.com
-
A.joins(:b) .where( A.arel_table[:something_a].eq('xxx').or(B.arel_table[:something_b].eq('yyy')) )
-
-
stackoverflow.com stackoverflow.com
-
If you need your grid to utilize a gap between columns / rows, you won't be able to use the gap property when using this method. You'd instead need to resort to some negative margin manipulation to handle the extra gap space.
-
-
alistapart.com alistapart.com
-
I hope we see new CSS capabilities arise that allow this sort of effect without the need for trickery.
-
Since CSS doesn’t (yet) offer a way to style grid cells, areas, or tracks directly, we have to stretch elements over the parts we want to style independently from the elements that contain content.
-
-
github.com github.com
-
proposes adding a grid-cell pseudo so you can add (responsive) decorative elements to grids without having to add empty elements to your page.
-
- Jan 2021
-
-
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.
-
-
-
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.
-
-
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
- elegant solution
- wrapper
- arbitrary limitations leading to less-than-ideal workarounds
- don't just complain; help improve/fix things
- proxy (programming)
- workarounds
- build your own
- good example
- Svelte: store: derived
- Svelte: store
- awkward workarounds
- missing feature leading to less-than-ideal workarounds
- clever
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
- forking to add a desired missing feature/change
- Svelte: how to affect child component styles
- 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)
- maintenance burden to explicitly define/enumerate/hard-code possible options (explicit interface)
- workarounds
- run-time dynamicness/generics vs. having to explicitly list/hard-code all options ahead of time
- ugly/kludgey
- trying to prevent one bad thing leading to people doing/choosing an even worse option
- component/library author can't consider/know ahead of time all of the ways users may want to use it
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
- Svelte: CSS encapsulation
- arbitrary limitations leading to less-than-ideal workarounds
- important point
- key point
- Svelte: how to affect child component styles
- +0.9
- missing out on the benefits of something
- trying to prevent one bad thing leading to people doing/choosing an even worse option
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
-