Core and Runtime
The core syntax parsing and runtime engine of Master CSS.
Master CSS
Create a Master CSS instance with your custom configuration:
import MasterCSS from '@master/css' const css = new MasterCSS(config)
.config
The .config
property is the result of extending the default config with the custom config you passed by the constructor.
css.config
.text
This .text
getter returns the result of joining the text of all CSS rules.
css.text
.add()
Add a new syntax class.
if (css.add('text:center')) { console.log('added')} else { console.log('not added')}
.delete()
Remove an existing syntax class.
css.delete('text:center')
.refresh()
Refresh the Master CSS with the configuration.
css.refresh(config)
.reset()
Clear all rules and reset to initial.
css.reset()
.destroy()
Destroy and remove the current instance from globalThis.masterCSSs
.
css.destroy()
MasterCSS.config
The default Master CSS configuration.
MasterCSS.config
Runtime CSS
The Runtime
extends the MasterCSS
and only works in the browser environment.
Create a Master Runtime CSS instance with your custom configuration:
import { RuntimeCSS } from '@master/css' const runtimeCSS = new RuntimeCSS(config)
.root
Observe the root element.
runtimeCSS.root
.host
Observe the root's host element, usually this.root.host
or document.documentElement
.
runtimeCSS.host
.container
Container for inserting style <style>
.
runtimeCSS.host
.observing
Observation state. true
after .observe()
; false
after .disconnect()
.
runtimeCSS.observing
.observe()
Observe the class
attribute changes of this.root
and all descendant elements.
runtimeCSS.observe()
.disconnect()
Cancel the previous .observe()
of this.root
.
runtimeCSS.disconnect()
.refresh()
Refresh the Master Runtime CSS with the configuration.
css.refresh(config)
.reset()
Clear all rules and styles and reset to initial.
css.reset()
.destroy()
Destroy and remove the current instance from globalThis.runtimeCSSs
.
css.reset()
Global
globalThis.runtimeCSS
Record the registered root document
Runtime CSS instance; the field will be recorded only after executing css.observe()
.
globalThis.runtimeCSSs
All objects instantiated via new RuntimeCSS()
.
globalThis.masterCSSs
All objects instantiated via new MasterCSS()
.
globalThis.RuntimeCSS
globalThis.MasterCSS
Functions
initRuntime()
Initializes the Master CSS runtime rendering engine.
import { initRuntime } from '@master/css' const css = initRuntime()
Equivalent to:
import { RuntimeCSS } from '@master/css' const runtimeCSS = new RuntimeCSS().observe()