Skip to content

Quirks mode switches in patches

Eilon Lipton edited this page Jan 17, 2018 · 3 revisions

A "quirks mode switch" is a switch to change behavior of an application without having to re-compile (or even re-deploy) an application. They are useful in patches where a behavior needs to be changed, but in case it inadvertently (or sometimes purposefully) introduces an unwanted change, the app developer or app administrator can revert the behavior to the pre-patch behavior.

In general, when patching, assume a quirks mode switch should be added. Only if there are good reasons to avoid a switch, don't add on. Such reasons may include technical challenges, such as where there is no simple if statement that can be used to change behavior, or it's a template change where the code is what it is.

A full quirks-mode example is available here: https://github.com/Eilon/QuirksModeSwitchSample

And here is an example of where we have used switches in the past:

Switch names should be descriptive, sort of like namespace/class/method names, e.g. Switch.Microsoft.AspNetCore.Mvc.AllowJsonHtml.

Quirks mode switches are currently used only in patches. Quirks mode switches are not used in major/minor versions.