UNPKG

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