Extends
Constructor
new ve.dm.ModelRegistry()
#
Hierarchy
Registry for models.
To register a new model type, call #register.
- Source:
Methods
isAnnotation(node) → {boolean}
#
Tests whether a node will be modelled as an annotation
Parameters:
| Name | Type | Description |
|---|---|---|
node |
Node | The node |
Returns:
Whether the element will be modelled as an annotation
- Type
- boolean
- Source:
matchElement(node, [aboutGroup], [excludeTypes]) → {string|null}
#
null}
#
Determine which model best matches the given node
Model matching works as follows:
Get all models whose tag and rdfaType rules match
Rank them in order of specificity:
- tag, rdfaType and func specified
- rdfaType and func specified
- tag and func specified
- func specified
- tag and rdfaType specified
- rdfaType specified
- tag specified
- nothing specified
If there are multiple candidates with the same specificity, exact matches of strings take precedence over matches of regular expressions. If there are still multiple candidates, they are ranked in reverse order of registration (i.e. if A was registered before B, B will rank above A). The highest-ranking model whose test function does not return false, wins.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
node |
Node | Node to match (usually an HTMLElement but can also be a Comment node) |
|
aboutGroup |
Array.<Node> |
optional |
If present and containing more than just node, only match models with about grouping enabled; will be passed to matchFunction |
excludeTypes |
Array.<string> |
optional |
Model names to exclude when matching |
Returns:
Model type, or null if none found
- Type
-
string
|
null
- Source:
Determine which model best matches the given node
Model matching works as follows:
Get all models whose tag and rdfaType rules match
Rank them in order of specificity:
- tag, rdfaType and func specified
- rdfaType and func specified
- tag and func specified
- func specified
- tag and rdfaType specified
- rdfaType specified
- tag specified
- nothing specified
If there are multiple candidates with the same specificity, exact matches of strings take precedence over matches of regular expressions.
register(constructor)
#
Register a model type.
Parameters:
| Name | Type | Description |
|---|---|---|
constructor |
ve.dm.Model | Subclass of |
Throws:
-
-
Model names must be strings and must not be empty
- Type
- Error
-
- Source:
unregister(constructor)
#
Unregister a model type.
Parameters:
| Name | Type | Description |
|---|---|---|
constructor |
ve.dm.Model | Subclass of |
Throws:
-
-
Model names must be strings and must not be empty
- Type
- Error
-
- Source: