Back to Top

Hype Style Caster master

Create and override inline styles or cast value changes to custom properties (CSS Vars)

setDefault(key, value)

This function allows to override a global default by key or if a object is given as key to override all default at once

Parameters

Name Type Description
key String

This is the key to override

value String Function Object

This is the value to set for the key

Returns

Void

getDefault(key)

This function returns the value of a default by key or all default if no key is given

Parameters

Name Type Description
key String

This the key of the default.

Returns

Returns the current value for a default with a certain key.

createStyleSheet(id)

Creates a style sheet with the given id and returns it.

Parameters

Name Type Description
id string
  • the id of the style sheet

Returns

HTMLStyleElement

the style sheet

registerCastingFunction(name, func)

This function registers a new casting function

Parameters

Name Type Description
name string
  • The name of the casting function
func function
  • The function to be registered

Returns

Void

resolveCastingFunction(cmd, value)

This function resolves the casting of the CSS property

Parameters

Name Type Description
cmd string
  • The casting command
value string
  • The value to be casted

Returns

string

  • Returns the casted value

isValidCSS(str)

This function checks if the string is a valid CSS property

Parameters

Name Type Description
str string
  • The string to be checked

Returns

boolean

  • Returns true if the string is a valid CSS property

insertStyle(id, style)

This function inserts the style into the style sheet

Parameters

Name Type Description
id string
  • The id of the element
style string
  • The style to be inserted

Returns

Void

removeStyle(id)

This function removes the style from the element

Parameters

Name Type Description
id string
  • The id of the element

Returns

Void

updateStyle(id, style)

This function updates the style of the element.

Parameters

Name Type Description
id string
  • The id of the element
style string
  • The style to be inserted

Returns

Void

setStyle(id, style)

This function sets the style of an element

Parameters

Name Type Description
id string
  • The id of the element
style object
  • The style object to be set

Returns

Void

styleToString(style)

This function converts a style object to a string

Parameters

Name Type Description
style object
  • The style object to be converted

Returns

string

  • Returns the style object as a string

resolveProp(prop)

This function resolves the CSS property

Parameters

Name Type Description
prop string
  • The CSS property to be resolved

Returns

array

  • Returns an array of the resolved CSS property

parseTransform(prop, string)

This function parses the transform property and returns the value of the property

Parameters

Name Type Description
prop string
  • The property to be parsed
string string
  • The string to be parsed

Returns

string

  • Returns the value of the property

removeStyleVariable(str, baseElm)

Remove a style variable from all elements in the base element

Parameters

Name Type Description
str string
  • the style variable to remove
baseElm HTMLElement
  • the base element to search in

Returns

Void

updateVarsForElementOnBase(styleVariableName, elm)

This function updates the CSS variables for the element

Parameters

Name Type Description
styleVariableName string
  • The name of the CSS variable
elm HTMLElement
  • The element to be updated

Returns

Void

updateVars(mutations)

This function updates the vars

Parameters

Name Type Description
mutations Array.<MutationRecord>
  • The mutations to be observed

Returns

Void

_local.updateTree(mutations)

This function updates the tree

Parameters

Name Type Description
mutations Array.<MutationRecord>
  • The mutations to be observed

Returns

Void

hypeDocument.setElementStyle(element, style)

This function sets the style of the element

Parameters

Name Type Description
element HTMLElement
  • The element to be styled
style string
  • The style to be applied to the element

Returns

Void