mobiledoc-dom-renderer
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -88,7 +88,12 @@ define('mobiledoc-dom-renderer/dom-renderer', ['exports'], function (exports) { | ||
var rendered = undefined; | ||
switch (type) { | ||
case 1: | ||
var rendered = this.renderParagraphSection(section); | ||
rendered = this.renderMarkupSection(section); | ||
utils.appendChild(this.root, rendered); | ||
break; | ||
case 2: | ||
rendered = this.renderImageSection(section); | ||
utils.appendChild(this.root, rendered); | ||
break; | ||
default: | ||
@@ -99,10 +104,22 @@ throw new Error('Unimplement renderer for type ' + type); | ||
}, { | ||
key: 'renderParagraphSection', | ||
value: function renderParagraphSection(_ref3) { | ||
var _ref32 = _slicedToArray(_ref3, 3); | ||
key: 'renderImageSection', | ||
value: function renderImageSection(_ref3) { | ||
var _ref32 = _slicedToArray(_ref3, 2); | ||
var type = _ref32[0]; | ||
var tagName = _ref32[1]; | ||
var markers = _ref32[2]; | ||
var src = _ref32[1]; | ||
var element = utils.createElement('img'); | ||
element.src = src; | ||
return element; | ||
} | ||
}, { | ||
key: 'renderMarkupSection', | ||
value: function renderMarkupSection(_ref4) { | ||
var _ref42 = _slicedToArray(_ref4, 3); | ||
var type = _ref42[0]; | ||
var tagName = _ref42[1]; | ||
var markers = _ref42[2]; | ||
var element = utils.createElement(tagName); | ||
@@ -109,0 +126,0 @@ var elements = [element]; |
@@ -283,7 +283,12 @@ ;(function() { | ||
var rendered = undefined; | ||
switch (type) { | ||
case 1: | ||
var rendered = this.renderParagraphSection(section); | ||
rendered = this.renderMarkupSection(section); | ||
utils.appendChild(this.root, rendered); | ||
break; | ||
case 2: | ||
rendered = this.renderImageSection(section); | ||
utils.appendChild(this.root, rendered); | ||
break; | ||
default: | ||
@@ -294,10 +299,22 @@ throw new Error('Unimplement renderer for type ' + type); | ||
}, { | ||
key: 'renderParagraphSection', | ||
value: function renderParagraphSection(_ref3) { | ||
var _ref32 = _slicedToArray(_ref3, 3); | ||
key: 'renderImageSection', | ||
value: function renderImageSection(_ref3) { | ||
var _ref32 = _slicedToArray(_ref3, 2); | ||
var type = _ref32[0]; | ||
var tagName = _ref32[1]; | ||
var markers = _ref32[2]; | ||
var src = _ref32[1]; | ||
var element = utils.createElement('img'); | ||
element.src = src; | ||
return element; | ||
} | ||
}, { | ||
key: 'renderMarkupSection', | ||
value: function renderMarkupSection(_ref4) { | ||
var _ref42 = _slicedToArray(_ref4, 3); | ||
var type = _ref42[0]; | ||
var tagName = _ref42[1]; | ||
var markers = _ref42[2]; | ||
var element = utils.createElement(tagName); | ||
@@ -304,0 +321,0 @@ var elements = [element]; |
@@ -92,2 +92,14 @@ module('JSHint - tests/jshint'); | ||
}); | ||
test('renders a mobiledoc with image section', function (assert) { | ||
var url = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs='; | ||
var mobiledoc = [[], // markers | ||
[// sections | ||
[2, url]]]; | ||
var rendered = renderer.render(mobiledoc); | ||
assert.equal(rendered.childNodes.length, 1, 'renders 1 section'); | ||
var sectionEl = rendered.childNodes[0]; | ||
assert.equal(sectionEl.src, url); | ||
}); | ||
}); |
@@ -51,7 +51,12 @@ /** | ||
const [type] = section; | ||
let rendered; | ||
switch (type) { | ||
case 1: | ||
let rendered = this.renderParagraphSection(section); | ||
rendered = this.renderMarkupSection(section); | ||
utils.appendChild(this.root, rendered); | ||
break; | ||
case 2: | ||
rendered = this.renderImageSection(section); | ||
utils.appendChild(this.root, rendered); | ||
break; | ||
default: | ||
@@ -62,3 +67,9 @@ throw new Error('Unimplement renderer for type ' + type); | ||
renderParagraphSection([type, tagName, markers]) { | ||
renderImageSection([type, src]) { | ||
let element = utils.createElement('img'); | ||
element.src = src; | ||
return element; | ||
} | ||
renderMarkupSection([type, tagName, markers]) { | ||
let element = utils.createElement(tagName); | ||
@@ -65,0 +76,0 @@ let elements = [element]; |
{ | ||
"name": "mobiledoc-dom-renderer", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
151788
4334
0