mobiledoc-dom-renderer
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -106,2 +106,3 @@ define('mobiledoc-dom-renderer/cards/image', ['exports', 'mobiledoc-dom-renderer/utils'], function (exports, _mobiledocDomRendererUtils) { | ||
case 1: | ||
// markup section | ||
rendered = this.renderMarkupSection(section); | ||
@@ -114,3 +115,9 @@ (0, _mobiledocDomRendererUtils.appendChild)(this.root, rendered); | ||
break; | ||
case 3: | ||
// list section | ||
rendered = this.renderListSection(section); | ||
(0, _mobiledocDomRendererUtils.appendChild)(this.root, rendered); | ||
break; | ||
case 10: | ||
// card section | ||
rendered = this.renderCardSection(section); | ||
@@ -124,9 +131,33 @@ (0, _mobiledocDomRendererUtils.appendChild)(this.root, rendered); | ||
}, { | ||
key: "renderImageSection", | ||
value: function renderImageSection(_ref4) { | ||
var _ref42 = _slicedToArray(_ref4, 2); | ||
key: "renderListSection", | ||
value: function renderListSection(_ref4) { | ||
var _this2 = this; | ||
var _ref42 = _slicedToArray(_ref4, 3); | ||
var type = _ref42[0]; | ||
var src = _ref42[1]; | ||
var tagName = _ref42[1]; | ||
var listItems = _ref42[2]; | ||
var element = (0, _mobiledocDomRendererUtils.createElement)(tagName); | ||
listItems.forEach(function (li) { | ||
element.appendChild(_this2.renderListItem(li)); | ||
}); | ||
return element; | ||
} | ||
}, { | ||
key: "renderListItem", | ||
value: function renderListItem(markers) { | ||
var element = (0, _mobiledocDomRendererUtils.createElement)('li'); | ||
this._renderMarkersOnElement(element, markers); | ||
return element; | ||
} | ||
}, { | ||
key: "renderImageSection", | ||
value: function renderImageSection(_ref5) { | ||
var _ref52 = _slicedToArray(_ref5, 2); | ||
var type = _ref52[0]; | ||
var src = _ref52[1]; | ||
var element = (0, _mobiledocDomRendererUtils.createElement)('img'); | ||
@@ -138,8 +169,8 @@ element.src = src; | ||
key: "renderCardSection", | ||
value: function renderCardSection(_ref5) { | ||
var _ref52 = _slicedToArray(_ref5, 3); | ||
value: function renderCardSection(_ref6) { | ||
var _ref62 = _slicedToArray(_ref6, 3); | ||
var type = _ref52[0]; | ||
var name = _ref52[1]; | ||
var payload = _ref52[2]; | ||
var type = _ref62[0]; | ||
var name = _ref62[1]; | ||
var payload = _ref62[2]; | ||
@@ -156,10 +187,16 @@ var card = this.cards[name]; | ||
key: "renderMarkupSection", | ||
value: function renderMarkupSection(_ref6) { | ||
var _ref62 = _slicedToArray(_ref6, 3); | ||
value: function renderMarkupSection(_ref7) { | ||
var _ref72 = _slicedToArray(_ref7, 3); | ||
var type = _ref62[0]; | ||
var tagName = _ref62[1]; | ||
var markers = _ref62[2]; | ||
var type = _ref72[0]; | ||
var tagName = _ref72[1]; | ||
var markers = _ref72[2]; | ||
var element = (0, _mobiledocDomRendererUtils.createElement)(tagName); | ||
this._renderMarkersOnElement(element, markers); | ||
return element; | ||
} | ||
}, { | ||
key: "_renderMarkersOnElement", | ||
value: function _renderMarkersOnElement(element, markers) { | ||
var elements = [element]; | ||
@@ -192,4 +229,2 @@ var currentElement = element; | ||
} | ||
return element; | ||
} | ||
@@ -232,2 +267,2 @@ }]); | ||
} | ||
}); | ||
});//# sourceMappingURL=mobiledoc-dom-renderer.map |
@@ -306,2 +306,3 @@ ;(function() { | ||
case 1: | ||
// markup section | ||
rendered = this.renderMarkupSection(section); | ||
@@ -314,3 +315,9 @@ (0, _mobiledocDomRendererUtils.appendChild)(this.root, rendered); | ||
break; | ||
case 3: | ||
// list section | ||
rendered = this.renderListSection(section); | ||
(0, _mobiledocDomRendererUtils.appendChild)(this.root, rendered); | ||
break; | ||
case 10: | ||
// card section | ||
rendered = this.renderCardSection(section); | ||
@@ -324,9 +331,33 @@ (0, _mobiledocDomRendererUtils.appendChild)(this.root, rendered); | ||
}, { | ||
key: "renderImageSection", | ||
value: function renderImageSection(_ref4) { | ||
var _ref42 = _slicedToArray(_ref4, 2); | ||
key: "renderListSection", | ||
value: function renderListSection(_ref4) { | ||
var _this2 = this; | ||
var _ref42 = _slicedToArray(_ref4, 3); | ||
var type = _ref42[0]; | ||
var src = _ref42[1]; | ||
var tagName = _ref42[1]; | ||
var listItems = _ref42[2]; | ||
var element = (0, _mobiledocDomRendererUtils.createElement)(tagName); | ||
listItems.forEach(function (li) { | ||
element.appendChild(_this2.renderListItem(li)); | ||
}); | ||
return element; | ||
} | ||
}, { | ||
key: "renderListItem", | ||
value: function renderListItem(markers) { | ||
var element = (0, _mobiledocDomRendererUtils.createElement)('li'); | ||
this._renderMarkersOnElement(element, markers); | ||
return element; | ||
} | ||
}, { | ||
key: "renderImageSection", | ||
value: function renderImageSection(_ref5) { | ||
var _ref52 = _slicedToArray(_ref5, 2); | ||
var type = _ref52[0]; | ||
var src = _ref52[1]; | ||
var element = (0, _mobiledocDomRendererUtils.createElement)('img'); | ||
@@ -338,8 +369,8 @@ element.src = src; | ||
key: "renderCardSection", | ||
value: function renderCardSection(_ref5) { | ||
var _ref52 = _slicedToArray(_ref5, 3); | ||
value: function renderCardSection(_ref6) { | ||
var _ref62 = _slicedToArray(_ref6, 3); | ||
var type = _ref52[0]; | ||
var name = _ref52[1]; | ||
var payload = _ref52[2]; | ||
var type = _ref62[0]; | ||
var name = _ref62[1]; | ||
var payload = _ref62[2]; | ||
@@ -356,10 +387,16 @@ var card = this.cards[name]; | ||
key: "renderMarkupSection", | ||
value: function renderMarkupSection(_ref6) { | ||
var _ref62 = _slicedToArray(_ref6, 3); | ||
value: function renderMarkupSection(_ref7) { | ||
var _ref72 = _slicedToArray(_ref7, 3); | ||
var type = _ref62[0]; | ||
var tagName = _ref62[1]; | ||
var markers = _ref62[2]; | ||
var type = _ref72[0]; | ||
var tagName = _ref72[1]; | ||
var markers = _ref72[2]; | ||
var element = (0, _mobiledocDomRendererUtils.createElement)(tagName); | ||
this._renderMarkersOnElement(element, markers); | ||
return element; | ||
} | ||
}, { | ||
key: "_renderMarkersOnElement", | ||
value: function _renderMarkersOnElement(element, markers) { | ||
var elements = [element]; | ||
@@ -392,4 +429,2 @@ var currentElement = element; | ||
} | ||
return element; | ||
} | ||
@@ -434,2 +469,2 @@ }]); | ||
require("mobiledoc-dom-renderer")["registerGlobal"](window, document); | ||
})(); | ||
})();//# sourceMappingURL=mobiledoc-dom-renderer.map |
@@ -1,24 +0,24 @@ | ||
module('JSHint - tests/jshint/cards'); | ||
test('tests/jshint/cards/image.js should pass jshint', function() { | ||
ok(true, 'tests/jshint/cards/image.js should pass jshint.'); | ||
QUnit.module('JSHint - tests/jshint/cards'); | ||
QUnit.test('tests/jshint/cards/image.js should pass jshint', function(assert) { | ||
assert.ok(true, 'tests/jshint/cards/image.js should pass jshint.'); | ||
}); | ||
module('JSHint - tests/jshint'); | ||
test('tests/jshint/dom-renderer.js should pass jshint', function() { | ||
ok(true, 'tests/jshint/dom-renderer.js should pass jshint.'); | ||
QUnit.module('JSHint - tests/jshint'); | ||
QUnit.test('tests/jshint/dom-renderer.js should pass jshint', function(assert) { | ||
assert.ok(true, 'tests/jshint/dom-renderer.js should pass jshint.'); | ||
}); | ||
module('JSHint - tests/jshint'); | ||
test('tests/jshint/index.js should pass jshint', function() { | ||
ok(true, 'tests/jshint/index.js should pass jshint.'); | ||
QUnit.module('JSHint - tests/jshint'); | ||
QUnit.test('tests/jshint/index.js should pass jshint', function(assert) { | ||
assert.ok(true, 'tests/jshint/index.js should pass jshint.'); | ||
}); | ||
module('JSHint - tests/jshint/unit'); | ||
test('tests/jshint/unit/dom-renderer-test.js should pass jshint', function() { | ||
ok(true, 'tests/jshint/unit/dom-renderer-test.js should pass jshint.'); | ||
QUnit.module('JSHint - tests/jshint/unit'); | ||
QUnit.test('tests/jshint/unit/dom-renderer-test.js should pass jshint', function(assert) { | ||
assert.ok(true, 'tests/jshint/unit/dom-renderer-test.js should pass jshint.'); | ||
}); | ||
module('JSHint - tests/jshint'); | ||
test('tests/jshint/utils.js should pass jshint', function() { | ||
ok(true, 'tests/jshint/utils.js should pass jshint.'); | ||
QUnit.module('JSHint - tests/jshint'); | ||
QUnit.test('tests/jshint/utils.js should pass jshint', function(assert) { | ||
assert.ok(true, 'tests/jshint/utils.js should pass jshint.'); | ||
}); | ||
@@ -36,3 +36,3 @@ | ||
var MOBILEDOC_VERSION = '0.1'; | ||
var MOBILEDOC_VERSION = '0.2.0'; | ||
@@ -185,2 +185,23 @@ var renderer = undefined; | ||
}); | ||
test('renders mobiledoc with lists', function (assert) { | ||
var mobiledoc = { | ||
version: MOBILEDOC_VERSION, | ||
sections: [[], [[3, 'ul', [[[[], 0, 'first item']], [[[], 0, 'second item']]]]]] | ||
}; | ||
var rendered = renderer.render(mobiledoc, document.createElement('div')); | ||
assert.equal(rendered.childNodes.length, 1, 'renders 1 section'); | ||
var section = rendered.childNodes[0]; | ||
assert.equal(section.tagName, 'UL'); | ||
var items = section.childNodes; | ||
assert.equal(items.length, 2, '2 list items'); | ||
assert.equal(items[0].tagName, 'LI', 'correct tagName for item 1'); | ||
assert.equal(items[0].childNodes[0].textContent, 'first item', 'correct text node for item 1'); | ||
assert.equal(items[1].tagName, 'LI', 'correct tagName for item 2'); | ||
assert.equal(items[1].childNodes[0].textContent, 'second item', 'correct text node for item 2'); | ||
}); | ||
}); |
@@ -54,3 +54,3 @@ import { | ||
switch (type) { | ||
case 1: | ||
case 1: // markup section | ||
rendered = this.renderMarkupSection(section); | ||
@@ -63,3 +63,7 @@ appendChild(this.root, rendered); | ||
break; | ||
case 10: | ||
case 3: // list section | ||
rendered = this.renderListSection(section); | ||
appendChild(this.root, rendered); | ||
break; | ||
case 10: // card section | ||
rendered = this.renderCardSection(section); | ||
@@ -73,2 +77,16 @@ appendChild(this.root, rendered); | ||
renderListSection([type, tagName, listItems]) { | ||
const element = createElement(tagName); | ||
listItems.forEach(li => { | ||
element.appendChild(this.renderListItem(li)); | ||
}); | ||
return element; | ||
} | ||
renderListItem(markers) { | ||
const element = createElement('li'); | ||
this._renderMarkersOnElement(element, markers); | ||
return element; | ||
} | ||
renderImageSection([type, src]) { | ||
@@ -91,3 +109,8 @@ let element = createElement('img'); | ||
renderMarkupSection([type, tagName, markers]) { | ||
let element = createElement(tagName); | ||
const element = createElement(tagName); | ||
this._renderMarkersOnElement(element, markers); | ||
return element; | ||
} | ||
_renderMarkersOnElement(element, markers) { | ||
let elements = [element]; | ||
@@ -115,5 +138,3 @@ let currentElement = element; | ||
} | ||
return element; | ||
} | ||
} |
{ | ||
"name": "mobiledoc-dom-renderer", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "Renders Mobiledoc input to DOM output", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
185651
3955
18
4749