StringComponent class abstract
A subclass of Component designed to be rendered through other RenderComponent using string interpolation.
The component needs to be attached to its parent RenderComponent by
calling _attachToRenderComponent
. Read ahead.
Because this component is not rendered independently, the parent component is responsible for calling the loadEventHandlers and unloadEventHandlers.
You use this component by calling asString
to get the raw unfiltered string
representation of this component. The string is then used (typically using
string interpolation) in other RenderComponent's baseInnerHtml, so that
this component can be rendered through DOM through that element. As a result,
you need to attach the component to the RenderComponent manually, so that
the component can be controlled when the parent RenderComponent is
rendered to DOM. You do this by supplying the parent component to
_attachToRenderComponent
.
- Inheritance
- Mixed-in types
- Implementers
Constructors
- StringComponent.new(RenderComponent parent, String id, String baseInnerHtml)
- StringComponent.empty(RenderComponent parent, String id)
Properties
- baseInnerElement → Element?
-
no setterinherited
- baseInnerHtml ↔ String
-
Unlike RenderComponent, setting the
baseInnerHtml
does not update baseInnerElement, because this component is not designed +to be rendered independently. You need to reprint the component to the parent's component (update itsbaseInnerHtml
with this component stringasString
), and re-attach it with_attachToRenderComponent
again.getter/setter pairinherited-getteroverride-setter - elem → Element
-
Returns the DOM
Element
of this component by doingquerySelector('$id')
.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- htmlElem → HTMLElement
-
no setterinherited
- id ↔ String
-
Setting the component with new ID is basically not recommended. It will
change the real HTML ID of this element rendered in DOM too, and will
throw ComponentDuplicateIdException when the new ID already exists.
getter/setter pairinherited
- mathMlElem → MathMLElement
-
no setterinherited
- parent → RenderComponent
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- svgElem → SVGElement
-
no setterinherited
Methods
-
addOnChangeTo(
Element node, void onChange(Event)) → void -
Creates an onChange event on
node
(has to be anElement
orDocument
type). Call this in loadEventHandlers.inherited -
addOnClickTo(
Element node, void onClick(Event)) → void -
Creates an onClick event on
node
(has to be anElement
orDocument
type). Call this in loadEventHandlers.inherited -
addSubscription(
StreamSubscription subs) → void -
A generic method to add an event subscription which will also get
cancelled when unloadEventHandlers is called.
inherited
-
addSubscriptions(
Iterable< StreamSubscription> subs) → void -
A generic method to add (bulk) event subscriptions which will also get
cancelled when unloadEventHandlers is called.
inherited
-
assertDuplicateId(
String id) → void -
inherited
-
assertElementAttached(
) → void -
contains(
Node node) → bool -
Contains checks whether a node is contained in this component.
Can only be used by StringComponent if the component has been attached.
inherited
-
isRendered(
) → bool -
Check if the component is rendered at DOM or not.
inherited
-
loadEventHandlers(
) → void -
Loads this component event handlers.
Call super to check whether this component has been attached. If it hasn't,
it will throw ComponentNotRenderedException.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onComponentAttached(
) → void - Called when this component has been attached to a parent RenderComponent.
-
queryByClass(
String elemClass) → NodeList -
Does elem.querySelectorAll(.elemClass) to select all
element that have matched class.
override
-
queryById(
String id) → Element? -
Does elem.querySelector(#id) to select an element under this
component.
override
-
toString(
) → String -
Returns this component representation as HTML string that you can use
inside other component's baseInnerHtml.
override
-
unloadEventHandlers(
) → void -
Unloads this component event handlers.
Call super to check whether this component has been attached. If it hasn't,
it will throw ComponentNotRenderedException.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited