new AppDataAttributeHandler()
Initilizes App, register surfaces and routes from data attributes.
Members
-
app :App
-
Holds the app reference initialized by data attributes.
Type:
- Default Value:
-
- null
-
baseElement :Element
-
Holds the base element to search initialization data attributes. This element is the container used to enable initialization based on the presence of `data-senna` attribute.
Type:
- Element
- Default Value:
-
- null
Methods
-
disposeInternal()
-
Disposes of this instance's object references.
-
getApp()
-
Gets the app reference.
Returns:
- Type
- App
-
getBaseElement()
-
Gets the base element.
Returns:
baseElement- Type
- Element
-
handle()
-
Inits application based on information scanned from document.
-
maybeAddRoutes_()
-
Maybe adds app routes from link elements that are `senna-route`.
-
maybeAddSurfaces_()
-
Maybe adds app surfaces by scanning `data-senna-surface` data attribute.
-
maybeDispatch_()
-
Dispatches app navigation to the current path when initializes.
-
maybeParseLinkRoute_(link)
-
Adds app route by parsing valid link elements. A valid link element is of the kind `rel="senna-route"`.
Parameters:
Name Type Description link
Element -
maybeParseLinkRouteHandler_(link)
-
Maybe parse link route handler.
Parameters:
Name Type Description link
Element Returns:
- Type
- string
-
maybeParseLinkRoutePath_(link)
-
Maybe parse link route path.
Parameters:
Name Type Description link
Element Returns:
- Type
- string
-
maybeSetBasePath_()
-
Maybe sets app base path from `data-senna-base-path` data attribute.
-
maybeSetLinkSelector_()
-
Maybe sets app link selector from `data-senna-link-selector` data attribute.
-
maybeSetLoadingCssClass_()
-
Maybe sets app link loading css class from `data-senna-loading-css-class` data attribute.
-
maybeSetUpdateScrollPosition_()
-
Maybe sets app update scroll position from `data-senna-update-scroll-position` data attribute.
-
querySelectorAllAsArray_(selector)
-
Queries elements from document and returns an array of elements.
Parameters:
Name Type Description selector
string Returns:
- Type
- array.<Element>
-
setBaseElement(baseElement)
-
Sets the base element.
Parameters:
Name Type Description baseElement
Element -
updateElementIdIfSpecialSurface_(element)
-
Updates element id if handled as special surface element. Some surfaces are slightly different from others, like when threating
body
as surface.Parameters:
Name Type Description element
Element