mobiledoc-dom-renderer
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -66,2 +66,3 @@ define('mobiledoc-dom-renderer/dom-renderer', ['exports'], function (exports) { | ||
var rootElement = arguments.length <= 1 || arguments[1] === undefined ? utils.createElement('div') : arguments[1]; | ||
var cards = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -75,2 +76,3 @@ var _mobiledoc = _slicedToArray(mobiledoc, 2); | ||
this.markerTypes = markerTypes; | ||
this.cards = cards; | ||
@@ -100,2 +102,6 @@ sections.forEach(function (section) { | ||
break; | ||
case 10: | ||
rendered = this.renderCardSection(section); | ||
utils.appendChild(this.root, rendered); | ||
break; | ||
default: | ||
@@ -118,10 +124,27 @@ throw new Error('Unimplement renderer for type ' + type); | ||
}, { | ||
key: 'renderMarkupSection', | ||
value: function renderMarkupSection(_ref4) { | ||
key: 'renderCardSection', | ||
value: function renderCardSection(_ref4) { | ||
var _ref42 = _slicedToArray(_ref4, 3); | ||
var type = _ref42[0]; | ||
var tagName = _ref42[1]; | ||
var markers = _ref42[2]; | ||
var name = _ref42[1]; | ||
var payload = _ref42[2]; | ||
var card = this.cards[name]; | ||
if (!card) { | ||
throw new Error('Cannot render unknown card named ' + name); | ||
} | ||
var element = utils.createElement('div'); | ||
card.display.setup(element, {}, { name: name }, payload); | ||
return element; | ||
} | ||
}, { | ||
key: 'renderMarkupSection', | ||
value: function renderMarkupSection(_ref5) { | ||
var _ref52 = _slicedToArray(_ref5, 3); | ||
var type = _ref52[0]; | ||
var tagName = _ref52[1]; | ||
var markers = _ref52[2]; | ||
var element = utils.createElement(tagName); | ||
@@ -128,0 +151,0 @@ var elements = [element]; |
@@ -261,2 +261,3 @@ ;(function() { | ||
var rootElement = arguments.length <= 1 || arguments[1] === undefined ? utils.createElement('div') : arguments[1]; | ||
var cards = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -270,2 +271,3 @@ var _mobiledoc = _slicedToArray(mobiledoc, 2); | ||
this.markerTypes = markerTypes; | ||
this.cards = cards; | ||
@@ -295,2 +297,6 @@ sections.forEach(function (section) { | ||
break; | ||
case 10: | ||
rendered = this.renderCardSection(section); | ||
utils.appendChild(this.root, rendered); | ||
break; | ||
default: | ||
@@ -313,10 +319,27 @@ throw new Error('Unimplement renderer for type ' + type); | ||
}, { | ||
key: 'renderMarkupSection', | ||
value: function renderMarkupSection(_ref4) { | ||
key: 'renderCardSection', | ||
value: function renderCardSection(_ref4) { | ||
var _ref42 = _slicedToArray(_ref4, 3); | ||
var type = _ref42[0]; | ||
var tagName = _ref42[1]; | ||
var markers = _ref42[2]; | ||
var name = _ref42[1]; | ||
var payload = _ref42[2]; | ||
var card = this.cards[name]; | ||
if (!card) { | ||
throw new Error('Cannot render unknown card named ' + name); | ||
} | ||
var element = utils.createElement('div'); | ||
card.display.setup(element, {}, { name: name }, payload); | ||
return element; | ||
} | ||
}, { | ||
key: 'renderMarkupSection', | ||
value: function renderMarkupSection(_ref5) { | ||
var _ref52 = _slicedToArray(_ref5, 3); | ||
var type = _ref52[0]; | ||
var tagName = _ref52[1]; | ||
var markers = _ref52[2]; | ||
var element = utils.createElement(tagName); | ||
@@ -323,0 +346,0 @@ var elements = [element]; |
@@ -21,2 +21,4 @@ module('JSHint - tests/jshint'); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _QUnit = QUnit; | ||
@@ -105,2 +107,27 @@ var test = _QUnit.test; | ||
}); | ||
test('renders a mobiledoc with card section', function (assert) { | ||
assert.expect(3); | ||
var cardName = 'title-card'; | ||
var payload = { | ||
name: 'bob' | ||
}; | ||
var TitleCard = { | ||
name: cardName, | ||
display: { | ||
setup: function setup(element, options, env, setupPayload) { | ||
assert.deepEqual(payload, setupPayload); | ||
element.innerHTML = setupPayload.name; | ||
} | ||
} | ||
}; | ||
var mobiledoc = [[], // markers | ||
[// sections | ||
[10, cardName, payload]]]; | ||
var rendered = renderer.render(mobiledoc, document.createElement('div'), _defineProperty({}, cardName, TitleCard)); | ||
assert.equal(rendered.childNodes.length, 1, 'renders 1 section'); | ||
var sectionEl = rendered.childNodes[0]; | ||
assert.equal(sectionEl.innerHTML, payload.name); | ||
}); | ||
}); |
{ | ||
"name": "mobiledoc-dom-renderer", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Renders Mobiledoc input to DOM output", | ||
@@ -5,0 +5,0 @@ "main": "dist/global/mobiledoc-dom-renderer.js", |
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
154832
4414