执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"use strict";
 
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const { childrenByHTMLLocalName } = require("../helpers/traversal");
const HTMLCollection = require("../generated/HTMLCollection");
const DOMException = require("domexception");
 
class HTMLTableSectionElementImpl extends HTMLElementImpl {
  get rows() {
    if (!this._rows) {
      this._rows = HTMLCollection.createImpl([], {
        element: this,
        query: () => childrenByHTMLLocalName(this, "tr")
      });
    }
    return this._rows;
  }
 
  insertRow(index) {
    if (index < -1 || index > this.rows.length) {
      throw new DOMException("Cannot insert a row at an index that is less than -1 or greater than the number of " +
        "existing rows", "IndexSizeError");
    }
 
    const tr = this._ownerDocument.createElement("tr");
 
    if (index === -1 || index === this.rows.length) {
      this.appendChild(tr);
    } else {
      const beforeTR = this.rows.item(index);
      this.insertBefore(tr, beforeTR);
    }
 
    return tr;
  }
 
  deleteRow(index) {
    if (index < -1 || index >= this.rows.length) {
      throw new DOMException(`Cannot delete a row at index ${index}, where no row exists`, "IndexSizeError");
    }
 
    if (index === -1) {
      if (this.rows.length > 0) {
        const tr = this.rows.item(this.rows.length - 1);
        this.removeChild(tr);
      }
    } else {
      const tr = this.rows.item(index);
      this.removeChild(tr);
    }
  }
}
 
module.exports = {
  implementation: HTMLTableSectionElementImpl
};