Skip to content

Commit e3a1284

Browse files
committed
DRY. Use uncircularOwnProperties defined in spec/utils.js
1 parent de55d85 commit e3a1284

2 files changed

Lines changed: 6 additions & 33 deletions

File tree

docs/parse.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
</tr>
2222
</table>
2323
<div id="message"></div>
24+
<script src="../spec/utils.js"></script>
2425
<script src="parse.js" defer></script>
2526
</body>
2627
</html>

docs/parse.js

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,6 @@ function makeIndent(depth) {
3434
makeIndent.cache = {};
3535

3636

37-
/**
38-
* buildPath(2) -> '../..'
39-
* @param {number} level
40-
* @return {string}
41-
*/
42-
function buildPath(level) {
43-
if (level === 0) {
44-
return '.';
45-
} else {
46-
var result = '..';
47-
for (var i = 1; i < level; i++) {
48-
result += '/..';
49-
}
50-
return result;
51-
}
52-
}
53-
54-
5537
/**
5638
* stringifyObjectKey('color') -> 'color'
5739
* stringifyObjectKey('background-color') -> '"background-color"'
@@ -72,16 +54,15 @@ function stringifyObjectKey(key) {
7254
function inspect(object) {
7355

7456
var root = document.createDocumentFragment();
75-
_inspect(root, object, 0, []);
57+
_inspect(root, object, 0);
7658
return root;
7759

7860
/**
7961
* @param {DocumentFragment} root
8062
* @param {Object} object
8163
* @param {number} depth
82-
* @param {Array} stack
8364
*/
84-
function _inspect(root, object, depth, stack) {
65+
function _inspect(root, object, depth) {
8566
switch (typeof object) {
8667
case 'object':
8768
case 'null': // ES 5.1
@@ -90,15 +71,7 @@ function inspect(object) {
9071
root.appendChild(document.createTextNode('null'));
9172
break;
9273
}
93-
94-
var level = stack.indexOf(object);
95-
if (level !== -1) {
96-
root.appendChild(document.createTextNode(buildPath(depth - level)));
97-
break;
98-
}
9974
depth++;
100-
var stackLength = stack.push(object);
101-
10275
var indent = document.createTextNode(makeIndent(depth));
10376
var span = document.createElement('span');
10477
span.textContent = ',\n';
@@ -115,8 +88,7 @@ function inspect(object) {
11588
root.appendChild(span);
11689
for (var i = 0; i < length; i++) {
11790
root.appendChild(indent.cloneNode(true));
118-
_inspect(root, object[i], depth, stack);
119-
stack.length = stackLength;
91+
_inspect(root, object[i], depth);
12092
if (i < length - 1) {
12193
root.appendChild(comma.cloneNode(true));
12294
}
@@ -143,8 +115,7 @@ function inspect(object) {
143115
root.appendChild(indent.cloneNode(true));
144116
root.appendChild(document.createTextNode(stringifyObjectKey(key)));
145117
root.appendChild(colon.cloneNode(true));
146-
_inspect(root, object[key], depth, stack);
147-
stack.length = stackLength;
118+
_inspect(root, object[key], depth);
148119
if (i < length - 1) {
149120
root.appendChild(comma.cloneNode(true));
150121
}
@@ -187,6 +158,7 @@ function outputUpdated() {
187158
if (value !== style.prevValue) {
188159
style.prevValue = value;
189160
var css = CSSOM.parse(value);
161+
uncircularOwnProperties(css);
190162
output.innerHTML = '';
191163
output.appendChild(inspect(css));
192164
serialized.innerHTML = css.toString();

0 commit comments

Comments
 (0)