执行过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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"use strict";
 
const DOMException = require("domexception");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const HTMLCollection = require("../generated/HTMLCollection");
const { HTML_NS } = require("../helpers/namespaces");
const { childrenByHTMLLocalNames } = require("../helpers/traversal");
const { domSymbolTree } = require("../helpers/internal-constants");
 
const cellLocalNames = new Set(["td", "th"]);
 
class HTMLTableRowElementImpl extends HTMLElementImpl {
  get cells() {
    if (!this._cells) {
      this._cells = HTMLCollection.createImpl([], {
        element: this,
        query: () => childrenByHTMLLocalNames(this, cellLocalNames)
      });
    }
    return this._cells;
  }
 
  get rowIndex() {
    const parent = this.parentElement;
    if (parent === null || parent.namespaceURI !== HTML_NS) {
      return -1;
    }
 
    let tableElement = parent;
    if (parent.localName === "thead" || parent.localName === "tbody" || parent.localName === "tfoot") {
      tableElement = parent.parentElement;
    }
    if (tableElement === null || tableElement.namespaceURI !== HTML_NS || tableElement.localName !== "table") {
      return -1;
    }
 
    return tableElement.rows.indexOf(this);
  }
 
  get sectionRowIndex() {
    const parent = domSymbolTree.parent(this);
    if (parent === null) {
      return -1;
    }
 
    const { rows } = parent;
    if (!rows) {
      return -1;
    }
 
    return rows.indexOf(this);
  }
 
  insertCell(index) {
    const td = this._ownerDocument.createElement("TD");
    const { cells } = this;
    if (index < -1 || index > cells.length) {
      throw new DOMException("The index is not in the allowed range.", "IndexSizeError");
    }
    if (index === -1 || index === cells.length) {
      this.appendChild(td);
    } else {
      const ref = cells.item(index);
      this.insertBefore(td, ref);
    }
    return td;
  }
 
  deleteCell(index) {
    const { cells } = this;
    if (index < -1 || index >= cells.length) {
      throw new DOMException("The index is not in the allowed range.", "IndexSizeError");
    }
    if (index === -1) {
      if (cells.length === 0) {
        return;
      }
 
      index = cells.length - 1;
    }
    const td = cells.item(index);
    this.removeChild(td);
  }
}
 
module.exports = {
  implementation: HTMLTableRowElementImpl
};