Questions tagged [fallback]

A fallback is a design pattern useful in situations, when certain advanced functionality may be used only if certain conditions are met. If the conditions cannot be fulfilled, algorithm reverts to the so-called fallback function, which achieves the goal using less sophisticated methods.

508 questions
9
votes
1 answer

How do I specify fallback fonts in Java2D/Graphics2D

I'm using g.drawString(str, x, y) to draw a String with a Graphics2D object g. The current font of g does not cover all the characters of str (I have e.g. Chinese chars in there). On Mac OS X, a fallback font seems to be automatically used, but not…
Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234
9
votes
2 answers

Deserialize Kotlin enum while ignoring unknown values

I have an enum that I'd like to deserialize from JSON using kotlinx.serialization while ignoring unknown values. This is the enum @Serializable enum class OperatingMode { Off, On, Auto } What I mean by ignoring unknowns is if I have a mode or…
Max
  • 21,123
  • 5
  • 49
  • 71
8
votes
0 answers

how to test fallback using react testing library

I'm looking for a way to test a React.Suspense fallback using react-testing-library. Consider this example: const MyLazyThing = lazy(() => import('./index')); export default function MyThing(props) { return (
Ben
  • 16,124
  • 22
  • 77
  • 122
8
votes
2 answers

jQuery .css() fallbacks?

What is the proper way to do fallbacks with .css()? This would most commonly be used for font fallbacks but I am using it for cursor images. Here's what I got that isn't working: $("#dragable").css('cursor','url(images/grabbing.gif), -moz-grabbing,…
Dave
  • 8,879
  • 10
  • 33
  • 46
8
votes
1 answer

Responsive image, picture vs img with srcset, fallback issue

After reading all day about one method or the other I am still not sure what is the best for me, all sites explain the same thing but when I want to know the things that really worries me, nobody talks about that. My case: I have almost all my…
AngelLestat
  • 127
  • 2
  • 7
8
votes
2 answers

How to wait for document.write to complete

I am trying to write some script fall-back code so that if jQuery and jQuery Validator is not available from a CDN I load a local version. Note that the following script is in a separate file to support Content Security Policy (CSP). (window.jQuery…
Muhammad Rehan Saeed
  • 35,627
  • 39
  • 202
  • 311
8
votes
2 answers

How to block Websocket protocol (to simulate corporate firewalls) on Ubuntu?

I am working on a web app that uses WebSockets, and I know that many corporate firewalls block it. Now I have added Socket.io to fallback to XHR polling in case Websockets are blocked. But I can't figure out how to simulate this environment for…
Deepak Joy Cheenath
  • 5,796
  • 5
  • 25
  • 29
8
votes
3 answers

HTML5 fallback images are being loaded by the browser, even though HTML5 video is supported

I have some HTML5 videos with animated GIFs as fallback. Sadly, the GIFs are being loaded even though HTML5 video is supported. Without using javascript, is there a way to stop the browser from downloading HTML5 fallback content? If not, I will just…
degenerate
  • 1,224
  • 1
  • 14
  • 35
7
votes
3 answers

Implementing level by level fallback

I have a class ScoreStrategy that describes how to calculate points for a quiz: public class ScoreStrategy { public int Id { get; set; } public int QuizId { get; set; } [Required] public Quiz Quiz { get; set; } public decimal…
Amal K
  • 4,359
  • 2
  • 22
  • 44
7
votes
2 answers

jquery.signalr CDN fallback

I use jQuery from Google CDN and fallback to local copy: