UNPKG

7.04 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16exports.DocHtmlAttribute = void 0;
17var DocNode_1 = require("./DocNode");
18var DocExcerpt_1 = require("./DocExcerpt");
19/**
20 * Represents an HTML attribute inside a DocHtmlStartTag or DocHtmlEndTag.
21 *
22 * Example: `href="#"` inside `<a href="#" />`
23 */
24var DocHtmlAttribute = /** @class */ (function (_super) {
25 __extends(DocHtmlAttribute, _super);
26 /**
27 * Don't call this directly. Instead use {@link TSDocParser}
28 * @internal
29 */
30 function DocHtmlAttribute(parameters) {
31 var _this = _super.call(this, parameters) || this;
32 if (DocNode_1.DocNode.isParsedParameters(parameters)) {
33 _this._nameExcerpt = new DocExcerpt_1.DocExcerpt({
34 configuration: _this.configuration,
35 excerptKind: DocExcerpt_1.ExcerptKind.HtmlAttribute_Name,
36 content: parameters.nameExcerpt
37 });
38 if (parameters.spacingAfterNameExcerpt) {
39 _this._spacingAfterNameExcerpt = new DocExcerpt_1.DocExcerpt({
40 configuration: _this.configuration,
41 excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
42 content: parameters.spacingAfterNameExcerpt
43 });
44 }
45 _this._equalsExcerpt = new DocExcerpt_1.DocExcerpt({
46 configuration: _this.configuration,
47 excerptKind: DocExcerpt_1.ExcerptKind.HtmlAttribute_Equals,
48 content: parameters.equalsExcerpt
49 });
50 if (parameters.spacingAfterEqualsExcerpt) {
51 _this._spacingAfterEqualsExcerpt = new DocExcerpt_1.DocExcerpt({
52 configuration: _this.configuration,
53 excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
54 content: parameters.spacingAfterEqualsExcerpt
55 });
56 }
57 _this._valueExcerpt = new DocExcerpt_1.DocExcerpt({
58 configuration: _this.configuration,
59 excerptKind: DocExcerpt_1.ExcerptKind.HtmlAttribute_Value,
60 content: parameters.valueExcerpt
61 });
62 if (parameters.spacingAfterValueExcerpt) {
63 _this._spacingAfterValueExcerpt = new DocExcerpt_1.DocExcerpt({
64 configuration: _this.configuration,
65 excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
66 content: parameters.spacingAfterValueExcerpt
67 });
68 }
69 }
70 else {
71 _this._name = parameters.name;
72 _this._spacingAfterName = parameters.spacingAfterName;
73 _this._spacingAfterEquals = parameters.spacingAfterEquals;
74 _this._value = parameters.value;
75 _this._spacingAfterValue = parameters.spacingAfterValue;
76 }
77 return _this;
78 }
79 Object.defineProperty(DocHtmlAttribute.prototype, "kind", {
80 /** @override */
81 get: function () {
82 return DocNode_1.DocNodeKind.HtmlAttribute;
83 },
84 enumerable: false,
85 configurable: true
86 });
87 Object.defineProperty(DocHtmlAttribute.prototype, "name", {
88 /**
89 * The HTML attribute name.
90 */
91 get: function () {
92 if (this._name === undefined) {
93 this._name = this._nameExcerpt.content.toString();
94 }
95 return this._name;
96 },
97 enumerable: false,
98 configurable: true
99 });
100 Object.defineProperty(DocHtmlAttribute.prototype, "spacingAfterName", {
101 /**
102 * Explicit whitespace that a renderer should insert after the HTML attribute name.
103 * If undefined, then the renderer can use a formatting rule to generate appropriate spacing.
104 */
105 get: function () {
106 if (this._spacingAfterName === undefined) {
107 if (this._spacingAfterNameExcerpt !== undefined) {
108 this._spacingAfterName = this._spacingAfterNameExcerpt.content.toString();
109 }
110 }
111 return this._spacingAfterName;
112 },
113 enumerable: false,
114 configurable: true
115 });
116 Object.defineProperty(DocHtmlAttribute.prototype, "spacingAfterEquals", {
117 /**
118 * Explicit whitespace that a renderer should insert after the "=".
119 * If undefined, then the renderer can use a formatting rule to generate appropriate spacing.
120 */
121 get: function () {
122 if (this._spacingAfterEquals === undefined) {
123 if (this._spacingAfterEqualsExcerpt !== undefined) {
124 this._spacingAfterEquals = this._spacingAfterEqualsExcerpt.content.toString();
125 }
126 }
127 return this._spacingAfterEquals;
128 },
129 enumerable: false,
130 configurable: true
131 });
132 Object.defineProperty(DocHtmlAttribute.prototype, "value", {
133 /**
134 * The HTML attribute value.
135 */
136 get: function () {
137 if (this._value === undefined) {
138 this._value = this._valueExcerpt.content.toString();
139 }
140 return this._value;
141 },
142 enumerable: false,
143 configurable: true
144 });
145 Object.defineProperty(DocHtmlAttribute.prototype, "spacingAfterValue", {
146 /**
147 * Explicit whitespace that a renderer should insert after the HTML attribute name.
148 * If undefined, then the renderer can use a formatting rule to generate appropriate spacing.
149 */
150 get: function () {
151 if (this._spacingAfterValue === undefined) {
152 if (this._spacingAfterValueExcerpt !== undefined) {
153 this._spacingAfterValue = this._spacingAfterValueExcerpt.content.toString();
154 }
155 }
156 return this._spacingAfterValue;
157 },
158 enumerable: false,
159 configurable: true
160 });
161 /** @override */
162 DocHtmlAttribute.prototype.onGetChildNodes = function () {
163 return [
164 this._nameExcerpt,
165 this._spacingAfterNameExcerpt,
166 this._equalsExcerpt,
167 this._spacingAfterEqualsExcerpt,
168 this._valueExcerpt,
169 this._spacingAfterValueExcerpt
170 ];
171 };
172 return DocHtmlAttribute;
173}(DocNode_1.DocNode));
174exports.DocHtmlAttribute = DocHtmlAttribute;
175//# sourceMappingURL=DocHtmlAttribute.js.map
\No newline at end of file