+2
-10
| { | ||
| "name": "h3", | ||
| "version": "1.0.0", | ||
| "description": "A better HTMLElement constructor", | ||
| "homepage": "https://github.com/twhb/h3-js", | ||
| "bugs": "https://github.com/twhb/h3-js/issues", | ||
| "license": "ISC", | ||
| "author": "Tristan Berger <tristanberger@gmail.com>", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/twhb/h3-js.git" | ||
| } | ||
| "version": "2.0.0", | ||
| "description": "DEPRECATED" | ||
| } |
+1
-38
@@ -1,38 +0,1 @@ | ||
| # h3-js | ||
| A better HTMLElement constructor | ||
| ## Example | ||
| ```javascript | ||
| var body = h('div', 'example', | ||
| h('h1', null, 'Example'), | ||
| h('label', {htmlFor: 'task'}, | ||
| h('input', {id: 'task', type: 'checkbox', checked: true}), | ||
| 'Check out h3-js' | ||
| ) | ||
| ); | ||
| ``` | ||
| ## API | ||
| ### h(tagName, props, ...children) | ||
| Creates and returns a new HTMLElement. | ||
| Primary interface: `tagName` sets the tag name, each key-value pair of `props` is copied onto the result, and each of `children` is appended to the result. | ||
| Conveniences: | ||
| - `props.style` sets `result.style.cssText` | ||
| - If `props` is falsy then it is ignored | ||
| - If `props` is a string then it instead sets `result.className` | ||
| - Children that are falsy are ignored | ||
| - Children that are strings are converted to `Text` instances | ||
| - Children that are Arrays are flattened into `children` | ||
| ## Setup | ||
| Install: `npm install h3` | ||
| Import: `const h = require('h3');` | ||
| DEPRECATED |
-53
| 'use strict'; | ||
| var doc = document; | ||
| function h(tagName, props) { | ||
| if (typeof tagName !== 'string') { | ||
| throw Error('tagName must be a string'); | ||
| } | ||
| var el = doc.createElement(tagName); | ||
| if (!props) { | ||
| // pass | ||
| } else if (typeof props === 'string') { | ||
| el.className = props; | ||
| } else if (typeof props === 'object') { | ||
| for (var key in props) { | ||
| if (key === 'style') { | ||
| el.style.cssText = props[key]; | ||
| } else { | ||
| el[key] = props[key]; | ||
| } | ||
| } | ||
| } else { | ||
| throw Error('props must be an object, a string, or falsy'); | ||
| } | ||
| var parent = el.content || el; | ||
| for (var i = 2, len = arguments.length; i < len; i++) { | ||
| append(parent, arguments[i]); | ||
| } | ||
| return el; | ||
| } | ||
| function append(parent, child) { | ||
| if (child instanceof Node) { | ||
| parent.appendChild(child); | ||
| } else if (typeof child === 'string') { | ||
| parent.appendChild(doc.createTextNode(child)); | ||
| } else if (!child) { | ||
| // pass | ||
| } else if (Array.isArray(child)) { | ||
| for (var i = 0, len = child.length; i < len; i++) { | ||
| append(parent, child[i]); | ||
| } | ||
| } else { | ||
| throw Error('children must be Nodes, strings, Arrays, or falsy'); | ||
| } | ||
| } | ||
| module.exports = h; |
-13
| Copyright (c) 2016, Tristan Berger <tristanberger@gmail.com> | ||
| Permission to use, copy, modify, and/or distribute this software for any purpose | ||
| with or without fee is hereby granted, provided that the above copyright notice | ||
| and this permission notice appear in all copies. | ||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
| REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
| FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
| OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
| TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
| THIS SOFTWARE. |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
LicenseLicense information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
81
-97.45%2
-50%1
Infinity%0
-100%2
100%1
-97.37%1
Infinity%1
Infinity%