Skip to content

Commit 23c55aa

Browse files
committed
Teach <cxx-section> to check for an id, and document the checkInvariants() function.
1 parent f867871 commit 23c55aa

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ Contributor License Agreement at https://developers.google.com/open-source/cla/i
1919
Custom C++-specific elements
2020
----------------------------
2121

22+
Some of these elements define a `checkInvariants()` method, so you can run:
23+
24+
document.querySelectorAll('*').array().forEach(
25+
function(node){ if (node.checkInvariants) node.checkInvariants(); });
26+
27+
to see if you've gotten anything wrong.
28+
2229
### `<cxx-include href="other.html">`
2330

2431
This one isn't really C++-specific: it allows partitioning a main document

section.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ limitations under the License.
2020

2121
applyAuthorStyles: true,
2222

23+
checkInvariants: function() {
24+
if (!this.id) {
25+
console.error(this, 'is missing an id.');
26+
}
27+
},
28+
2329
update_sec_nums: function(sec_num) {
2430
this.sec_num = sec_num + '';
2531
var child_index = 1;

0 commit comments

Comments
 (0)