|
147 | 147 | ? elems
|
148 | 148 | : [];
|
149 | 149 | this.raw = raw != null ? raw : '';
|
150 |
| - Object.defineProperty(this, 'id', { |
151 |
| - set: function(it){ |
152 |
| - return this.attrs.id = it; |
153 |
| - } |
154 |
| - }); |
155 |
| - Object.defineProperty(this, 'width', { |
156 |
| - set: function(it){ |
157 |
| - return this.attrs.width = it; |
158 |
| - } |
159 |
| - }); |
160 |
| - Object.defineProperty(this, 'height', { |
161 |
| - set: function(it){ |
162 |
| - return this.attrs.height = it; |
163 |
| - } |
164 |
| - }); |
165 |
| - Object.defineProperty(this, 'className', { |
166 |
| - set: function(it){ |
167 |
| - return this.attrs['class'] = it; |
168 |
| - } |
169 |
| - }); |
170 |
| - Object.defineProperty(this, 'innerHTML', { |
171 |
| - get: function(){ |
172 |
| - return this.raw || join$.call(this.elems.map(function(it){ |
173 |
| - return it.outerHTML; |
174 |
| - }), "\n"); |
175 |
| - }, |
176 |
| - set: function(it){ |
177 |
| - return this.raw = it; |
178 |
| - } |
179 |
| - }); |
180 |
| - Object.defineProperty(this, 'outerHTML', { |
181 |
| - get: function(){ |
182 |
| - var tag, attrs, style, k, v, css; |
183 |
| - tag = this.tag, attrs = this.attrs, style = this.style; |
184 |
| - css = style.cssText || (function(){ |
185 |
| - var ref$, results$ = []; |
186 |
| - for (k in ref$ = style) { |
187 |
| - v = ref$[k]; |
188 |
| - results$.push(k + ":" + v); |
189 |
| - } |
190 |
| - return results$; |
191 |
| - }()).join(";"); |
192 |
| - if (css) { |
193 |
| - attrs.style = css; |
194 |
| - } else { |
195 |
| - delete attrs.style; |
| 150 | + } |
| 151 | + Object.defineProperty(prototype, 'id', { |
| 152 | + set: function(id){ |
| 153 | + this.attrs.id = id; |
| 154 | + }, |
| 155 | + configurable: true, |
| 156 | + enumerable: true |
| 157 | + }); |
| 158 | + Object.defineProperty(prototype, 'width', { |
| 159 | + set: function(width){ |
| 160 | + this.attrs.width = width; |
| 161 | + }, |
| 162 | + configurable: true, |
| 163 | + enumerable: true |
| 164 | + }); |
| 165 | + Object.defineProperty(prototype, 'height', { |
| 166 | + set: function(height){ |
| 167 | + this.attrs.height = height; |
| 168 | + }, |
| 169 | + configurable: true, |
| 170 | + enumerable: true |
| 171 | + }); |
| 172 | + Object.defineProperty(prototype, 'className', { |
| 173 | + set: function($class){ |
| 174 | + this.attrs['class'] = $class; |
| 175 | + }, |
| 176 | + configurable: true, |
| 177 | + enumerable: true |
| 178 | + }); |
| 179 | + Object.defineProperty(prototype, 'innerHTML', { |
| 180 | + set: function(raw){ |
| 181 | + this.raw = raw; |
| 182 | + }, |
| 183 | + get: function(){ |
| 184 | + return this.raw || join$.call(this.elems.map(function(it){ |
| 185 | + return it.outerHTML; |
| 186 | + }), "\n"); |
| 187 | + }, |
| 188 | + configurable: true, |
| 189 | + enumerable: true |
| 190 | + }); |
| 191 | + Object.defineProperty(prototype, 'outerHTML', { |
| 192 | + get: function(){ |
| 193 | + var tag, attrs, style, k, v, css; |
| 194 | + tag = this.tag, attrs = this.attrs, style = this.style; |
| 195 | + css = style.cssText || (function(){ |
| 196 | + var ref$, results$ = []; |
| 197 | + for (k in ref$ = style) { |
| 198 | + v = ref$[k]; |
| 199 | + results$.push(k + ":" + v); |
196 | 200 | }
|
197 |
| - return "<" + tag + (function(){ |
198 |
| - var ref$, results$ = []; |
199 |
| - for (k in ref$ = attrs) { |
200 |
| - v = ref$[k]; |
201 |
| - results$.push(" " + k + "=\"" + v + "\""); |
202 |
| - } |
203 |
| - return results$; |
204 |
| - }()).join("") + ">" + this.innerHTML + "</" + tag + ">"; |
| 201 | + return results$; |
| 202 | + }()).join(";"); |
| 203 | + if (css) { |
| 204 | + attrs.style = css; |
| 205 | + } else { |
| 206 | + delete attrs.style; |
205 | 207 | }
|
206 |
| - }); |
207 |
| - } |
| 208 | + return "<" + tag + (function(){ |
| 209 | + var ref$, results$ = []; |
| 210 | + for (k in ref$ = attrs) { |
| 211 | + v = ref$[k]; |
| 212 | + results$.push(" " + k + "=\"" + v + "\""); |
| 213 | + } |
| 214 | + return results$; |
| 215 | + }()).join("") + ">" + this.innerHTML + "</" + tag + ">"; |
| 216 | + }, |
| 217 | + configurable: true, |
| 218 | + enumerable: true |
| 219 | + }); |
208 | 220 | prototype.appendChild = function(it){
|
209 | 221 | return this.elems.push(it);
|
210 | 222 | };
|
|
0 commit comments