Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

DOMBuilder

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

DOMBuilder - npm Package Compare versions

Comparing version 2.1.3 to 2.1.4

53

lib/dombuilder/core.js

@@ -28,2 +28,3 @@ var is = require('isomorph/lib/is')

)
/**

@@ -37,2 +38,15 @@ * Element name for fragments.

/**
* Regular Expression which parses out tag names with optional id and class
* definitions as part of the tag name.
* @const
* @type {RegExp}
*/
var BUILD_TAG_RE = new RegExp(
'^([a-z]+)?' // tag name
+ '(?:#([a-z][-:\\w]*))?' // id, excluding leading '#'
+ '(?:\\.([-\\w]+(?:\\.[-\\w]+)*))?' // class(es), excluding leading '.'
, 'i'
)
/**
* Tag names defined in the HTML 4.01 Strict and Frameset DTDs and new elements

@@ -351,5 +365,7 @@ * from HTML5.

, build: function(content, mode) {
// Default to the configured output mode if called without one
mode = mode || this.mode
var elementName = content[0]
, isFragment = (elementName == FRAGMENT_NAME)
var tagName = content[0]
, isFragment = (tagName == FRAGMENT_NAME)
, attrs = (!isFragment && isPlainObject(content[1], mode)

@@ -360,16 +376,39 @@ ? content[1]

, l = content.length
, built = []
, children = []
, item
// Extract id and classes from tagName for non-fragment elements, defaulting
// the tagName to 'div' if none was specified.
if (!isFragment) {
if (attrs === null) {
attrs = {}
}
var tagParts = BUILD_TAG_RE.exec(tagName)
if (!tagParts) {
throw new Error(tagName + ' is not a valid tag definition')
}
tagName = tagParts[1] || 'div'
if (tagParts[2]) {
attrs.id = tagParts[2]
}
if (tagParts[3]) {
attrs['class'] = tagParts[3].replace(/\./g, ' ')
}
}
// Build child contents first
for (var i = childStartIndex; i < l; i++) {
item = content[i]
if (is.Array(item)) {
built.push(this.build(item, mode))
children.push(this.build(item, mode))
}
else {
built.push(item)
children.push(item)
}
}
// Build the current element
return (isFragment
? this.modes[mode].fragment(built)
: this.modes[mode].createElement(elementName, attrs, built))
? this.modes[mode].fragment(children)
: this.modes[mode].createElement(tagName, attrs, children))
}

@@ -376,0 +415,0 @@

2

package.json
{
"name": "DOMBuilder"
, "description": "Builder library - generate HTML with an API which is also usable in the browser"
, "version": "2.1.3"
, "version": "2.1.4"
, "author": "Jonathan Buchanan <jonathan.buchanan@gmail.com> (https://github.com/insin)"

@@ -6,0 +6,0 @@ , "tags": ["dualsided", "DOM", "HTML", "builder", "templates"]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc