Comparing version 17.2.0 to 17.3.0
# CHANGELOG | ||
## 17.3.0 | ||
Allow to use attribute selectors in pseudo css definitions. Example: `b.styleDef({},{ "[aria-disabled=\"true\"]": { opacity: 0.5 } })` | ||
## 17.2.0 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "bobril", | ||
"version": "17.2.0", | ||
"version": "17.3.0", | ||
"description": "Component Oriented MVC Framework with virtual DOM and CSS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,3 +15,3 @@ import { CSSStyles, CSSPseudoStyles, CSSStylesItem, CSSInlineStyles } from "./cssTypes"; | ||
} from "./core"; | ||
import { assert, hOP, newHashObj, noop } from "./localHelpers"; | ||
import { assert, createTextNode, hOP, newHashObj, noop } from "./localHelpers"; | ||
import { isArray, isFunction, isNumber, isObject, isString } from "./isFunc"; | ||
@@ -482,3 +482,5 @@ import { setBeforeFrame } from "./frameCallbacks"; | ||
styleStr += | ||
(name == undefined ? parent + ":" + key2 : buildCssRule(parent, name + ":" + key2)) + | ||
(name == undefined | ||
? parent + addDoubleDot(key2) | ||
: buildCssRule(parent, name + addDoubleDot(key2))) + | ||
" {" + | ||
@@ -504,8 +506,3 @@ inlineStyleToCssDeclaration(item) + | ||
var styleElement = document.createElement("style"); | ||
styleElement.type = "text/css"; | ||
if ((<any>styleElement).styleSheet) { | ||
(<any>styleElement).styleSheet.cssText = styleStr; | ||
} else { | ||
styleElement.appendChild(document.createTextNode(styleStr)); | ||
} | ||
styleElement.appendChild(createTextNode(styleStr)); | ||
@@ -524,2 +521,10 @@ var head = document.head || document.getElementsByTagName("head")[0]; | ||
function addDoubleDot(pseudoOrElse: string) { | ||
var c = pseudoOrElse.charCodeAt(0); | ||
if (c == 32 || c == 0x5b || c == 0x2e) | ||
// " ", "[", "." | ||
return pseudoOrElse; | ||
return ":" + pseudoOrElse; | ||
} | ||
export function style(node: IBobrilNode, ...styles: IBobrilStyles[]): IBobrilNode { | ||
@@ -601,4 +606,4 @@ let className = node.className; | ||
export function styleDef(style: CSSStyles, pseudo?: CSSPseudoStyles, nameHint?: string): IBobrilStyleDef { | ||
return styleDefEx(undefined, style, pseudo, nameHint); | ||
export function styleDef(style: CSSStyles, pseudoOrAttr?: CSSPseudoStyles, nameHint?: string): IBobrilStyleDef { | ||
return styleDefEx(undefined, style, pseudoOrAttr, nameHint); | ||
} | ||
@@ -678,5 +683,5 @@ | ||
style: CSSStyles, | ||
pseudo?: CSSPseudoStyles | ||
pseudoOrAttr?: CSSPseudoStyles | ||
): IBobrilStyleDef { | ||
var res = styleDefEx(parent, style, pseudo, name); | ||
var res = styleDefEx(parent, style, pseudoOrAttr, name); | ||
if (res != name) throw new Error("named style " + name + " is not unique"); | ||
@@ -686,4 +691,4 @@ return res; | ||
export function namedStyleDef(name: string, style: CSSStyles, pseudo?: CSSPseudoStyles): IBobrilStyleDef { | ||
return namedStyleDefEx(name, undefined, style, pseudo); | ||
export function namedStyleDef(name: string, style: CSSStyles, pseudoOrAttr?: CSSPseudoStyles): IBobrilStyleDef { | ||
return namedStyleDefEx(name, undefined, style, pseudoOrAttr); | ||
} | ||
@@ -694,3 +699,3 @@ | ||
style: CSSStyles, | ||
pseudo?: CSSPseudoStyles, | ||
pseudoOrAttr?: CSSPseudoStyles, | ||
nameHint?: string | ||
@@ -704,5 +709,5 @@ ): IBobrilStyleDef { | ||
style, | ||
pseudo, | ||
pseudo: pseudoOrAttr, | ||
}; | ||
if (isString(style) && pseudo == undefined) { | ||
if (isString(style) && pseudoOrAttr == undefined) { | ||
allStyles[nameHint]!.realName = style; | ||
@@ -713,3 +718,3 @@ } else invalidateStyles(); | ||
export function selectorStyleDef(selector: string, style: CSSStyles, pseudo?: CSSPseudoStyles) { | ||
export function selectorStyleDef(selector: string, style: CSSStyles, pseudoOrAttr?: CSSPseudoStyles) { | ||
allStyles["b-" + globalCounter++] = { | ||
@@ -720,3 +725,3 @@ name: null, | ||
style, | ||
pseudo, | ||
pseudo: pseudoOrAttr, | ||
}; | ||
@@ -723,0 +728,0 @@ invalidateStyles(); |
@@ -24,1 +24,5 @@ // PureFuncs: noop, newHashObj, is, hOP, assert | ||
} | ||
export function createTextNode(content: string): Text { | ||
return document.createTextNode(content); | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
387372
9271
6