mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
feat: Add prefixfree (#34164)
* feat: Add `prefixfree` * chore(prefixfree): Require TypeScript 2.8 * fix(prefixfree): Enable `strictNullChecks` Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
3
types/prefixfree/.editorconfig
Normal file
3
types/prefixfree/.editorconfig
Normal file
@@ -0,0 +1,3 @@
|
||||
# This package uses tabs
|
||||
[*]
|
||||
indent_style = tab
|
||||
72
types/prefixfree/index.d.ts
vendored
Normal file
72
types/prefixfree/index.d.ts
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
// Type definitions for prefixfree 1.0
|
||||
// Project: https://github.com/LeaVerou/prefixfree
|
||||
// Definitions by: ExE Boss <https://github.com/ExE-Boss>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
declare namespace StyleFix {
|
||||
type StyleFixer = (css: string, raw: boolean, element: Element) => string;
|
||||
}
|
||||
|
||||
interface StyleFix {
|
||||
fix: StyleFix.StyleFixer;
|
||||
fixers?: StyleFix.StyleFixer[];
|
||||
optIn: boolean;
|
||||
camelCase(str: string): string;
|
||||
deCamelCase(str: string): string;
|
||||
link(link: HTMLLinkElement): void;
|
||||
process(): void;
|
||||
register(fixer: StyleFix.StyleFixer, index?: number): void;
|
||||
styleAttribute(element: ElementCSSInlineStyle): void;
|
||||
styleElement(style: HTMLStyleElement): void;
|
||||
}
|
||||
|
||||
declare const StyleFix: StyleFix;
|
||||
|
||||
// PrefixFree
|
||||
declare namespace PrefixFree {
|
||||
/** The known prefixes used for CSS properties. */
|
||||
type KnownPrefixCSS = "-moz-" | "-ms-" | "-o-" | "-webkit-";
|
||||
|
||||
/** The known prefixes used for CSS properties in `CSSStyleDeclaration`. */
|
||||
type KnownPrefixJS = "Moz" | "Ms" | "O" | "Webkit";
|
||||
}
|
||||
|
||||
interface PrefixFree {
|
||||
/**
|
||||
* The prefix used for CSS properties.
|
||||
*
|
||||
* Eg.: `-moz-`, `-ms-`, `-o-` or `-webkit-`.
|
||||
*/
|
||||
prefix: PrefixFree.KnownPrefixCSS | string;
|
||||
|
||||
/**
|
||||
* The prefix used for CSS properties in `CSSStyleDeclaration`.
|
||||
*
|
||||
* Eg.: `Moz`, `Ms`, `O` or `Webkit`.
|
||||
*/
|
||||
Prefix: PrefixFree.KnownPrefixJS | string;
|
||||
|
||||
atrules: string[];
|
||||
functions: string[];
|
||||
keywords: string[];
|
||||
properties: string[];
|
||||
selectorMap: {
|
||||
[selector: string]: string;
|
||||
};
|
||||
selectors: string[];
|
||||
valueProperties: string[];
|
||||
|
||||
prefixCSS: StyleFix.StyleFixer;
|
||||
prefixProperty(property: string, camelCase?: boolean): string;
|
||||
prefixSelector(selector: string): string;
|
||||
property(property: string): string;
|
||||
value(value: string, property?: string): string;
|
||||
}
|
||||
|
||||
declare const PrefixFree: PrefixFree;
|
||||
|
||||
interface Window {
|
||||
StyleFix: StyleFix;
|
||||
PrefixFree: PrefixFree;
|
||||
}
|
||||
27
types/prefixfree/prefixfree-tests.ts
Normal file
27
types/prefixfree/prefixfree-tests.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
window.StyleFix === StyleFix;
|
||||
window.PrefixFree === PrefixFree;
|
||||
|
||||
StyleFix.register((css, raw, element) => {
|
||||
return css + "\n/* Custom end comment */\n";
|
||||
});
|
||||
StyleFix.process();
|
||||
|
||||
const browser = (() => {
|
||||
switch (PrefixFree.prefix) {
|
||||
case "-moz-":
|
||||
return "firefox";
|
||||
case "-ms-":
|
||||
return "ie";
|
||||
case "-o-":
|
||||
return "opera";
|
||||
case "-webkit-":
|
||||
return "chrome";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
})();
|
||||
|
||||
// $ExpectError
|
||||
if (browser === "safari") {
|
||||
// There's no way to differentiate Safari from Chrome using just prefixes
|
||||
}
|
||||
24
types/prefixfree/tsconfig.json
Normal file
24
types/prefixfree/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"dom",
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"prefixfree-tests.ts"
|
||||
]
|
||||
}
|
||||
9
types/prefixfree/tslint.json
Normal file
9
types/prefixfree/tslint.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"indent": [
|
||||
true,
|
||||
"tabs"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user