Constructor
new SectionSkeleton(parser, heading, targets)
- Source:
Create a section skeleton instance.
Parameters:
Name | Type | Description |
---|---|---|
parser |
Parser | |
heading |
object | |
targets |
Array.<object> |
Members
comments :Array.<Comment>
- Source:
Comments contained in the section.
Type:
- Array.<Comment>
commentsInFirstChunk :Array.<Comment>
- Source:
Comments contained in the first chunk of the section, i.e. all elements up to the first subheading if it is present, or all elements if it is not.
Type:
- Array.<Comment>
editUrl :string
- Source:
URL to edit the section.
Type:
- string
headingElement :Element|external:Element
- Source:
Heading element (.mw-heading
or <h1>
- <h6>
).
Type:
- Element | external:Element
headline :string
- Source:
Section headline as it appears on the page.
Foreign elements can get there, add the classes of these elements to module:defaultConfig.excludeFromHeadlineClasses to filter them out.
Type:
- string
headlineElement :Element|external:Element
- Source:
Headline element.
Type:
- Element | external:Element
hElement :Element|external:Element
- Source:
H1...6
element.
Type:
- Element | external:Element
id :string
- Source:
Section id.
Type:
- string
index :number
- Source:
Section index. Same as the index in the array returned by module:sectionRegistry.getAll.
Type:
- number
lastElement :Element|external:Element
- Source:
Last element in the section.
Type:
- Element | external:Element
lastElementInFirstChunk :Element|external:Element
- Source:
Last element in the first chunk of the section, i.e. all elements up to the first subheading if it is present or just all elements if it is not.
Type:
- Element | external:Element
level :number
- Source:
Section level. A level is a number representing the number of =
characters in the section
heading's code.
Type:
- number
oldestComment :CommentSkeleton
- Source:
Oldest comment in the section.
Type:
(nullable) sectionNumber :number
- Source:
Sequental number of the section at the time of the page load.
Type:
- number
Methods
getAncestors() → {Array.<SectionSkeleton>}
- Source:
Get the chain of ancestors of the section as an array, starting with the parent section.
The returned value is cached, so don't change the array in-place. (That's ugly, need to check if running .slice() on the array slows anything down. To be clear – this method is run very frequently.)
Returns:
- Type
- Array.<SectionSkeleton>
getLastElement(followingHeadingElement, treeWalker) → {Element|external:Element}
- Source:
Get the last element in the section based on a following (directly or not) section's heading element.
Sometimes sections are nested trickily in some kind of container elements, so a following structure may take place:
== Heading 1 ==
<p>Paragraph 1.</p>
<div>
<p>Paragraph 2.</p>
== Heading 2 ==
<p>Paragraph 3.</p>
</div>
<p>Paragraph 4.</p>
== Heading 3 ==
In this case, section 1 has paragraphs 1 and 2 as the first and last, and section 2 has paragraphs 3 and 4 as such. Our code must capture that.
Parameters:
Name | Type | Description |
---|---|---|
followingHeadingElement |
Element | external:Element | undefined | |
treeWalker |
TreeWalker |
Returns:
- Type
- Element | external:Element
getParent(ignoreFirstLevelopt) → (nullable) {SectionSkeleton}
- Source:
Get the parent section of the section.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ignoreFirstLevel |
boolean |
<optional> |
true
|
Don't consider sections of the first level parent sections; stop at second level sections. |
Returns:
- Type
- SectionSkeleton
parseHeadline()
- Source:
For internal use. Parse the headline of the section and fill the headline property that contains no HTML tags.