Comparing version 1.4.22 to 1.5.0
@@ -6,3 +6,3 @@ { | ||
"author": "rackai", | ||
"version": "1.4.22", | ||
"version": "1.5.0", | ||
"repository": "https://github.com/rackai/domql", | ||
@@ -9,0 +9,0 @@ "publishConfig": { |
@@ -13,3 +13,3 @@ 'use strict' | ||
if (pushState) window.history.pushState(state, null, route) | ||
rootElement.set({ proto: content }) | ||
rootElement.set({ extend: content }) | ||
.node.scrollIntoView({ behavior: 'smooth' }) | ||
@@ -16,0 +16,0 @@ } |
@@ -43,3 +43,3 @@ # DOMQL | ||
var ListItem = { | ||
proto: Link, | ||
extend: Link, | ||
class: 'ui link', | ||
@@ -52,3 +52,3 @@ attr: { | ||
var menu = { | ||
childProto: ListItem, | ||
childExtend: ListItem, | ||
home: 'Home', | ||
@@ -67,3 +67,3 @@ text: 'About' | ||
var menu = { | ||
proto: ListItem, | ||
extend: ListItem, | ||
...navItems | ||
@@ -95,4 +95,4 @@ } | ||
| `key` | `Number` `String` | Defines the key of the Element | The key of the object, or randomly generated name | | ||
| `proto` | `Object` `Array` | Clones the other element | `undefined` | | ||
| `childProto` | `Object` `Array` | Specifies the `proto` for all child elements | `undefined` | | ||
| `extend` | `Object` `Array` | Clones the other element | `undefined` | | ||
| `childExtend` | `Object` `Array` | Specifies the `extend` for all child elements | `undefined` | | ||
| `tag` | `String` | Specifis the HTML tag | `div` or related HTML tag if the key matches | | ||
@@ -115,3 +115,3 @@ | `class` | `Any` | Specifies the HTML class | `undefined` | | ||
var Contact = { | ||
proto: User, | ||
extend: User, | ||
username: 'nikoloza' | ||
@@ -139,3 +139,3 @@ } | ||
node | ||
proto | ||
extend | ||
on | ||
@@ -152,3 +152,3 @@ class | ||
Anything except these keywords will create a new nested child element. The easier method to specify HTML tag is to use related nodeName as a key, for example: | ||
Anything except these keywords will create a new nested child element. The easier method to specify HTML tag is to use related nodeName as a key, for example: | ||
@@ -160,3 +160,3 @@ ```javascript | ||
main: { // will create <main> | ||
childProto: { | ||
childExtend: { | ||
article: { // will create <article> | ||
@@ -163,0 +163,0 @@ title: {}, // will create <div> |
@@ -6,3 +6,3 @@ 'use strict' | ||
import { appendNode, assignNode } from './assign' | ||
import { applyPrototype } from './proto' | ||
import { applyExtendtype } from './extend' | ||
import nodes from './nodes' | ||
@@ -31,5 +31,5 @@ import set from './set' | ||
// if element is proto | ||
// if element is extend | ||
if (element.__hash) { | ||
element = { proto: element } | ||
element = { extend: element } | ||
} | ||
@@ -39,6 +39,6 @@ | ||
const { components } = options | ||
const { proto, component } = element | ||
if (isString(proto)) | ||
if (components[proto]) element.proto = components[proto] | ||
else console.warn(proto, 'is not in library', components, element) | ||
const { extend, component } = element | ||
if (isString(extend)) | ||
if (components[extend]) element.extend = components[extend] | ||
else console.warn(extend, 'is not in library', components, element) | ||
} | ||
@@ -57,3 +57,3 @@ | ||
text: element, | ||
tag: (!element.proto && parent.childProto && parent.childProto.tag) || | ||
tag: (!element.extend && parent.childExtend && parent.childExtend.tag) || | ||
((nodes.body.indexOf(key) > -1) && key) || 'string' | ||
@@ -65,7 +65,7 @@ } | ||
applyPrototype(element, parent, options) | ||
applyExtendtype(element, parent, options) | ||
if (Object.keys(options).length) { | ||
registry.defaultOptions = options | ||
if (options.ignoreChildProto) delete options.ignoreChildProto | ||
if (options.ignoreChildExtend) delete options.ignoreChildExtend | ||
} | ||
@@ -72,0 +72,0 @@ |
@@ -24,6 +24,6 @@ 'use strict' | ||
proto: {}, | ||
extend: {}, | ||
props: {}, | ||
path: {}, | ||
childProto: {}, | ||
childExtend: {}, | ||
if: {}, | ||
@@ -40,3 +40,3 @@ define: {}, | ||
__props: {}, | ||
__proto: {}, | ||
__extend: {}, | ||
__ifFragment: {}, | ||
@@ -43,0 +43,0 @@ __ifFalsy: {}, |
@@ -40,6 +40,6 @@ 'use strict' | ||
if (isArray(element.__proto)) { | ||
element.__proto.map(proto => { | ||
if (proto.props) propsStack.push(proto.props) | ||
return proto.props | ||
if (isArray(element.__extend)) { | ||
element.__extend.map(extend => { | ||
if (extend.props) propsStack.push(extend.props) | ||
return extend.props | ||
}) | ||
@@ -46,0 +46,0 @@ } |
@@ -28,6 +28,6 @@ 'use strict' | ||
if (params) { | ||
const { childProto } = params | ||
if (!childProto && element.childProto) params.childProto = element.childProto | ||
const { childExtend } = params | ||
if (!childExtend && element.childExtend) params.childExtend = element.childExtend | ||
create(params, element, 'content', { | ||
ignoreChildProto: true, | ||
ignoreChildExtend: true, | ||
...registry.defaultOptions | ||
@@ -34,0 +34,0 @@ }) |
@@ -6,2 +6,2 @@ 'use strict' | ||
export * from './node' | ||
export * from './protoUtils' | ||
export * from './extendUtils' |
'use strict' | ||
export const cleanWithNode = proto => delete proto.node && proto | ||
export const cleanWithNode = extend => delete extend.node && extend | ||
@@ -5,0 +5,0 @@ export const createID = (function * () { |
@@ -74,13 +74,13 @@ 'use strict' | ||
export const deepMerge = (element, proto) => { | ||
export const deepMerge = (element, extend) => { | ||
// console.groupCollapsed('deepMerge:') | ||
for (const e in proto) { | ||
for (const e in extend) { | ||
const elementProp = element[e] | ||
const protoProp = proto[e] | ||
const extendProp = extend[e] | ||
// const cachedProps = cache.props | ||
if (e === 'parent' || e === 'props' || e === 'state') continue | ||
if (elementProp === undefined) { | ||
element[e] = protoProp | ||
} else if (isObjectLike(elementProp) && isObject(protoProp)) { | ||
deepMerge(elementProp, protoProp) | ||
element[e] = extendProp | ||
} else if (isObjectLike(elementProp) && isObject(extendProp)) { | ||
deepMerge(elementProp, extendProp) | ||
} | ||
@@ -109,3 +109,3 @@ } | ||
let objProp = obj[prop] | ||
if (prop === 'proto' && isArray(objProp)) { | ||
if (prop === 'extend' && isArray(objProp)) { | ||
objProp = mergeArray(objProp) | ||
@@ -169,3 +169,3 @@ } | ||
/** | ||
* Merges array prototypes | ||
* Merges array extends | ||
*/ | ||
@@ -177,3 +177,3 @@ export const mergeArray = (arr) => { | ||
/** | ||
* Merges array prototypes | ||
* Merges array extends | ||
*/ | ||
@@ -191,4 +191,4 @@ export const mergeAndCloneIfArray = obj => { | ||
const protoOfProto = objectized[prop] | ||
if (protoOfProto) flattenRecursive(protoOfProto, prop, stack) | ||
const extendOfExtend = objectized[prop] | ||
if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack) | ||
@@ -195,0 +195,0 @@ delete objectized[prop] |
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
54683