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 |
- Source:
Returns:
Whether the element will be modelled as an annotation
- Type
- boolean
matchElement(node, [forceAboutGrouping], [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) |
|
forceAboutGrouping |
boolean |
optional |
If true, only match models with about grouping enabled |
excludeTypes |
Array.<string> |
optional |
Model names to exclude when matching |
- Source:
Returns:
Model type, or null if none found
- Type
-
string
|
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.
register(constructor)
#
Register a model type.
Parameters:
Name | Type | Description |
---|---|---|
constructor |
ve.dm.Model | Subclass of |
- Source:
Throws:
unregister(constructor)
#
Unregister a model type.
Parameters:
Name | Type | Description |
---|---|---|
constructor |
ve.dm.Model | Subclass of |
- Source: