Extends superclass
Mixin to create Adaptive Web Component classes.
The current AdaptiveVariant instance for this component.
Returns AdaptiveVariant the current variant's instance.
Indicates if this component is managing its decentants or behaves transparent in terms of PROFILE_REQUEST_EVENTs from the decentants in its shadow DOM.
Returns Boolean true
if the component is managing, false
if not.
Sets this component to managing mode or transparent mode (default). In managing mode, it manages the adaptation behavior of the decentants in its shadow DOM. In transparent mode, it does not influence the bubbling of PROFILE_REQUEST_EVENTs comming from its shadow DOM.
Parameters
flag
Booleantrue
to set the component to managing mode,false
to set it to transparent mode.
Indicates if this components adaptation is managed by another component. If in managed mode, this component does not itself listen to PROFILE_CHANGED_EVENTs. Instead, the managing component will call AdaptiveComponent#prepareAdaptation and AdaptiveComponent#performAdaptation directly.
Returns Boolean true
if the component is managed, false
if not.
Called when the instance of the component has been connected to, i.e. inserted into a document.
Called when the instance of the component has been disconnected from, i.e. removed from a document.
Called when an attribute was added, removed or modified at the instance of the component.
Parameters
attrName
String The name of the changed attribute.oldVal
Any The old value of the attribute.newVal
Any The new value of the attribute.
Called when the instance of the component has been adopted by another document.
Parameters
oldDocument
Document The document the element has been taken from.newDocument
Document The document the element has been adpoted by.
Prepares the adaptation of the component according to the given profile.
Parameters
profile
Object The profile to adapt to.
Performes the adaptation of the component according to the given profile.
Parameters
profile
Object The profile to adapt to.
Removes a component from the list of managed components. Typically because it has been removed from the shadow DOM of this component and should therefore no further be managed.
Parameters
component
AdaptiveComponent The component to be removed.
Defines the attributes that are observed, i.e. for which attributes the #attributeChangedCallback will be called.
Registers a variant for this component.
Parameters
variant
Class The subclass of AdaptiveVariant to register.
Sets an already registered variant as the default variant for this component.
Parameters
-
variant
Class The registered subclass of AdaptiveVariant that should be used as default variant. -
Throws Error If 'variant' is not a registered variant of this component.
Returns Class The subclass of AdaptiveVariant set as default variant.
Prefix for all attributes related to the adaptive web components framework.
Type: string
A variant of an Adaptive Web Component.
Returns DocumentFragment
Returns Node The node that contains the variant's DOM contents, e.g. the shadow root.
Sets the node that contains the variant's DOM contents.
Parameters
node
Node The node that contains the variant's DOM contents, e.g. the shadow root.
Called when the variant has been selected as the current variant for the owning component.
Parameters
state
Object The internal state the variant should take up
Called when the variant has been deselected as the current variant for the owning component.
Returns Object The internal state of the variant
Called after the variant has been connected to the component's content root.
Called after the variant's contents have been removed from the component's content root.
Checks if the variant matches the given context.
Parameters
profile
Object
A ContextQuery
object represents a context query expression, and handles sending notifications to
listeners when the context query state changes (i.e. when it starts or stops matching the current context).
It mainly replicates the interface of
MediaQueryList.
Parameters
query
String The query expression thisContextQuery
represents, defaults to empty string and therefore a query that matches any context (alwaystrue
). (optional, default""
)attachTo
EventTarget Specifies the node thisContextQuery
will dispatch the PROFILE_REQUEST_EVENT to, defaults towindow
. (optional, defaultwindow
)
The original query expression.
Returns String The original query expression.
Checks if this ContextQuery
matches the current context as known by the node it is attached to.
Returns Boolean true
if this query matches the current context, false
if not.
Sets a function as event handler for the change
event, i.e. when the status of the query changes.
Parameters
handler
Function The function to be called on change with the event object as parameter ornull
to remove the current handler.
The function as event handler for the change
event, i.e. when the status of the query changes.
Returns Function The function currently set as change
event handler or null
if no
current handler is set.
Add the specified function to the list of listeners to be called when an event of the specified type occurs. This is basically an optionless version of EventTarget.addEventListener.
Parameters
type
String A string representing the event type to listen for. Onlychange
events are expected to occur onContextQuery
objects.listener
Function The function to be called on change with the event object as parameter.
Remove the specified function from the list of listeners to be called for the specified event type. This is basically an optionless version of EventTarget.removeEventListener.
Parameters
type
String A string which specifies the event type for which to remove a listener.listener
Function The listener function that should be removed from the list.
Dispatches the specified event.
Parameters
event
Event The event to dispatch.
Prepares the adaptation of the component according to the given profile.
Parameters
profile
Object The profile to adapt to.
Performes the adaptation of the component according to the given profile.
Parameters
profile
Object The profile to adapt to.
Parameters
query
String
Extends HTMLElement
The context-style
custom element polyfills CSS @context
rules.
Parameters
attr
string the query from the "context" attribute
Parameters
url
string the link to an external context query sheet
Parameters
str
string the styles found inside the custom elementattr
string the query of the "context" attribute
Parameters
brackets
string the type of brackets as pair [],{},()str
string the string where the brackets are to be found
Parameters
str
string the content of the custom elementattr
string the content of the context attribute, false if the context attribute is empty
Extends ProfileStore
A ProfileStore implementation based on HTML5 Local Storage.
Parameters
attachTo
EventTarget Specifies the node this ProfileStore is attached to and dispatches its events to. (optional, defaultwindow
)
Allows to request a value change of profile properties. It returns a promise to
Parameters
newValues
Object A map of the requested property changes. JSON structured like{ propertyName: newValue , ... }
.
The storage key used for storing the profile.
Type: string
Simple volatile in-memory profile store. Mainly serves as a base class for implementations that represent different sources, storage locations or fetch methods for user interface profiles.
Parameters
changeable
Boolean Specifies if the store supports to change the stored profile. (optional, defaultfalse
)attachTo
EventTarget Specifies the node this ProfileStore is attached to and dispatches its events to. (optional, defaultwindow
)
The current profile
Type: Object
The current user interface profile.
Returns Promise A promise to the current user interface profile.
Indicates if changes of the profile are supported.
Returns Boolean true
if profile store supports to change the profile, false
if not.
Allows to request a value change of profile properties. It returns the effective changes.
Parameters
newValues
Object<String, Any?> A map of the requested property changes. JSON structured like{ propertyName: newValue , ... }
.
Returns Promise A promise to the effective changes.
Creates and dispatches a profile changed event containing information on changed values of profile properties.
Parameters
diff
ProfileDiff A data structure describing the last changes to the profile properties. Expected to be structured like{ propertyName: { from: oldValue, to: newValue }, ... }
.
The type of the CustomEvent that is triggered when a profile has been changed.
Type: string
The type of CustomEvents that represent a request to provide the current profile.
Type: string
An object representing the value change of a profile property.
Type: Object
Properties
from
Any? the old value ornull
to
Any? the new value ornull
A structured object describing the changes that occurred or have been made to a profile.
Each changed profile property is represented by its property name. The value of this property
is an object with a from
property representing the old value and a to
property representing the new current value. If from
is null
,
the property has just been added. Accordingly, if to
is null
,
the property has been removed from the profile.
Type: Object<String, ProfileChange>
Examples
{
changed: {from: 1, to: 5},
new: {from: null, to: 'foo'},
removed: {from: true, to: null}
}