New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hybrids

Package Overview
Dependencies
Maintainers
2
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hybrids - npm Package Compare versions

Comparing version 7.0.5 to 7.0.6

8

docs/CHANGELOG.md

@@ -5,2 +5,10 @@ # Changelog

### [7.0.6](https://github.com/hybridsjs/hybrids/compare/v7.0.5...v7.0.6) (2022-04-15)
### Bug Fixes
* **parent/child:** Add host argument to parent and child factories. ([#188](https://github.com/hybridsjs/hybrids/issues/188)) ([3d0dc3a](https://github.com/hybridsjs/hybrids/commit/3d0dc3ac23b49a5b7936580a06e69acf1f39c2f8))
* **store:** clear should invalidate models with cache set to true ([55ca7fa](https://github.com/hybridsjs/hybrids/commit/55ca7fa0283d6f33f6057008085852547646605f))
### [7.0.5](https://github.com/hybridsjs/hybrids/compare/v7.0.4...v7.0.5) (2022-02-03)

@@ -7,0 +15,0 @@

6

docs/component-model/parent-children.md

@@ -12,3 +12,3 @@ # Parent & Children

```typescript
parent(componentOrFn: Object | Function: (component) => {...}: Boolean): Object
parent(componentOrFn: Object | Function: (component, host) => {...}: Boolean): Object
```

@@ -51,3 +51,3 @@

```typescript
children(componentOrFn: Object | Function: (component) => {...}: Boolean, [options: Object]): Object
children(componentOrFn: Object | Function: (component, host) => {...}: Boolean, [options: Object]): Object
```

@@ -98,3 +98,3 @@

parent: parent(component => component === MyElement),
// any children, that has `value` property

@@ -101,0 +101,0 @@ items: children(component => component.hasOwnProperty("value")),

@@ -11,6 +11,6 @@ # API Reference

* **arguments**:
* `component` - an object with map of hybrid property descriptors with a tag name set to `tag` property
* **returns**:
* `component` - a passed argument to `define()` function
- **arguments**:
- `component` - an object with map of hybrid property descriptors with a tag name set to `tag` property
- **returns**:
- `component` - a passed argument to `define()` function

@@ -21,6 +21,6 @@ ```typescript

* **arguments**:
* `component` - an object with map of hybrid property descriptors without `tag` property
* **returns**:
* `HTMLElement` - a constructor for the custom element (not registered in the global custom elements registry)
- **arguments**:
- `component` - an object with map of hybrid property descriptors without `tag` property
- **returns**:
- `HTMLElement` - a constructor for the custom element (not registered in the global custom elements registry)

@@ -30,9 +30,9 @@ ## Parent

```typescript
parent(componentOrFn: Object | Function: (component) => {...}: Boolean): Object
parent(componentOrFn: Object | Function: (component, host) => {...}: Boolean): Object
```
* **arguments**:
* `componentOrFn` - reference to an object containing property descriptors or a function, which returns `true` when current `component` meets the condition
* **returns**:
* a property descriptor, which resolves to `null` or `Element` instance
- **arguments**:
- `componentOrFn` - reference to an object containing property descriptors or a function, which returns `true` when current `component` meets the condition
- **returns**:
- a property descriptor, which resolves to `null` or `Element` instance

@@ -42,12 +42,12 @@ ## Children

```typescript
children(componentOrFn: Object | Function: (component) => {...}: Boolean, [options: Object]): Object
children(componentOrFn: Object | Function: (component, host) => {...}: Boolean, [options: Object]): Object
```
* **arguments**:
* `componentOrFn` - reference to an object containing property descriptors or a function, which returns `true` when current `component` meets the condition
* `options` - object with available keys:
* `deep` - boolean, defaults to `false`
* `nested` - boolean, defaults to `false`
* **returns**:
* a property descriptor, which resolves to `array` of `Element` instances
- **arguments**:
- `componentOrFn` - reference to an object containing property descriptors or a function, which returns `true` when current `component` meets the condition
- `options` - object with available keys:
- `deep` - boolean, defaults to `false`
- `nested` - boolean, defaults to `false`
- **returns**:
- a property descriptor, which resolves to `array` of `Element` instances

@@ -60,7 +60,7 @@ ## Templates

* **arguments**:
* HTML content as a template content
* `value` - dynamic values as a property values or element content
* **returns**:
* an update function, which takes `host` and `target` arguments
- **arguments**:
- HTML content as a template content
- `value` - dynamic values as a property values or element content
- **returns**:
- an update function, which takes `host` and `target` arguments

@@ -71,6 +71,6 @@ ```typescript

* **arguments**:
* `map` - object with hybrids definitions or custom element's constructors
* **returns**:
* update function compatible with content expression
- **arguments**:
- `map` - object with hybrids definitions or custom element's constructors
- **returns**:
- update function compatible with content expression

@@ -81,6 +81,6 @@ ```typescript

* **arguments**:
* `styles` - a list of text contents of CSS stylesheets, or instances of `CSSStyleSheet` (only for constructable stylesheets)
* **returns**:
* an update function compatible with content expression
- **arguments**:
- `styles` - a list of text contents of CSS stylesheets, or instances of `CSSStyleSheet` (only for constructable stylesheets)
- **returns**:
- an update function compatible with content expression

@@ -91,7 +91,7 @@ ```typescript

* **arguments**:
* CSS content in tagged template literals
* `value` - dynamic values concatenated with the template literal
* **returns**:
* an update function compatible with content expression
- **arguments**:
- CSS content in tagged template literals
- `value` - dynamic values concatenated with the template literal
- **returns**:
- an update function compatible with content expression

@@ -102,8 +102,8 @@ ```typescript

* **arguments**:
* `promise` - promise, which should resolve to content expression value
* `placeholder` - update function for render content until promise is resolved or rejected
* `delay` - delay in milliseconds, after which placeholder is rendered
* **returns**:
* update function compatible with content expression
- **arguments**:
- `promise` - promise, which should resolve to content expression value
- `placeholder` - update function for render content until promise is resolved or rejected
- `delay` - delay in milliseconds, after which placeholder is rendered
- **returns**:
- update function compatible with content expression

@@ -114,7 +114,7 @@ ```typescript

* **arguments**:
* SVG content as a template content
* `value` - dynamic values as a property values or element content
* **returns**:
* an update function, which takes `host` and `target` arguments
- **arguments**:
- SVG content as a template content
- `value` - dynamic values as a property values or element content
- **returns**:
- an update function, which takes `host` and `target` arguments

@@ -125,6 +125,6 @@ ```typescript

* **arguments**:
* `map` - object with hybrids definitions or custom element's constructors
* **returns**:
* update function compatible with content expression
- **arguments**:
- `map` - object with hybrids definitions or custom element's constructors
- **returns**:
- update function compatible with content expression

@@ -135,6 +135,6 @@ ```typescript

* **arguments**:
* `styles` - text content of CSS stylesheet
* **returns**:
* update function compatible with content expression
- **arguments**:
- `styles` - text content of CSS stylesheet
- **returns**:
- update function compatible with content expression

@@ -145,7 +145,7 @@ ```typescript

* **arguments**:
* CSS content in tagged template literals
* `value` - dynamic values concatenated with the template literal
* **returns**:
* an update function compatible with content expression
- **arguments**:
- CSS content in tagged template literals
- `value` - dynamic values concatenated with the template literal
- **returns**:
- an update function compatible with content expression

@@ -156,8 +156,8 @@ ```typescript

* **arguments**:
* `promise` - promise, which should resolve/reject update function
* `placeholder` - update function for render content until promise is resolved or rejected
* `delay` - delay in milliseconds, after which placeholder is rendered
* **returns**:
* update function compatible with content expression
- **arguments**:
- `promise` - promise, which should resolve/reject update function
- `placeholder` - update function for render content until promise is resolved or rejected
- `delay` - delay in milliseconds, after which placeholder is rendered
- **returns**:
- update function compatible with content expression

@@ -170,12 +170,12 @@ ## Dispatch

* **arguments**:
* `host` - element instance
* `eventType` - type of the event to be dispatched
* `options` - a dictionary, having the following optional fields:
* `bubbles` - a boolean indicating whether the event bubbles. The default is false
* `cancelable` - a boolean indicating whether the event can be cancelled. The default is false
* `composed` - a boolean indicating whether the event will trigger listeners outside of a shadow root The default is false
* `detail` - a custom data, which will be passed to an event listener
* **returns**:
* `false` if event is cancelable and at least one of the event handlers which handled this event called `preventDefault()`, otherwise it returns `true`
- **arguments**:
- `host` - element instance
- `eventType` - type of the event to be dispatched
- `options` - a dictionary, having the following optional fields:
- `bubbles` - a boolean indicating whether the event bubbles. The default is false
- `cancelable` - a boolean indicating whether the event can be cancelled. The default is false
- `composed` - a boolean indicating whether the event will trigger listeners outside of a shadow root The default is false
- `detail` - a custom data, which will be passed to an event listener
- **returns**:
- `false` if event is cancelable and at least one of the event handlers which handled this event called `preventDefault()`, otherwise it returns `true`

@@ -190,7 +190,7 @@ ## Store

* **arguments**:
* `Model: object` - a model definition
* `id: string | object` - a string or an object representing identifier of the model instance
* **returns**:
* Model instance or model instance placeholder
- **arguments**:
- `Model: object` - a model definition
- `id: string | object` - a string or an object representing identifier of the model instance
- **returns**:
- Model instance or model instance placeholder

@@ -201,8 +201,8 @@ ```typescript

* **arguments**:
* `Model: object` - a model definition
* `values: object` - an object with partial values of the model instance
* **returns**:
* A promise, which resolves with the model instance
- **arguments**:
- `Model: object` - a model definition
- `values: object` - an object with partial values of the model instance
- **returns**:
- A promise, which resolves with the model instance
```typescript

@@ -212,7 +212,7 @@ store.set(modelInstance: object, values: object | null): Promise;

* **arguments**:
* `modelInstance: object` - a model instance
* `values: object | null` - an object with partial values of the model instance or `null` for deleting the model
* **returns**:
* A promise, which resolves to the model instance or placeholder (for model deletion)
- **arguments**:
- `modelInstance: object` - a model instance
- `values: object | null` - an object with partial values of the model instance or `null` for deleting the model
- **returns**:
- A promise, which resolves to the model instance or placeholder (for model deletion)

@@ -223,7 +223,7 @@ ```typescript

* **arguments**:
* `modelOrDefinition` - a model instance or model definition
* `values` - an object with partial values of the model instance or `null` for deleting the model
* **returns**:
* Model instance or model instance placeholder
- **arguments**:
- `modelOrDefinition` - a model instance or model definition
- `values` - an object with partial values of the model instance or `null` for deleting the model
- **returns**:
- Model instance or model instance placeholder

@@ -234,5 +234,5 @@ ```typescript

* **arguments**:
* `model` - a model definition (for all instances) or a model instance (for a specific one)
* `clearValue` - indicates if the cached value should be deleted (`true`), or it should only notify the cache mechanism, that the value expired, but leaves the value untouched (`false`)
- **arguments**:
- `model` - a model definition (for all instances) or a model instance (for a specific one)
- `clearValue` - indicates if the cached value should be deleted (`true`), or it should only notify the cache mechanism, that the value expired, but leaves the value untouched (`false`)

@@ -245,9 +245,9 @@ ### Factory

* **arguments**:
* `Model` - a model definition
* `options` - an object with following options:
* `id` - a `host` property name, or a function returning the identifier using the `host`
* `draft` - a boolean switch for the draft mode, where the property returns a copy of the model instance for the form manipulation
* **returns**:
* a hybrid property descriptor, which resolves to a store model instance
- **arguments**:
- `Model` - a model definition
- `options` - an object with following options:
- `id` - a `host` property name, or a function returning the identifier using the `host`
- `draft` - a boolean switch for the draft mode, where the property returns a copy of the model instance for the form manipulation
- **returns**:
- a hybrid property descriptor, which resolves to a store model instance

@@ -258,6 +258,6 @@ ```typescript

* **arguments**:
* `Model` - an instance of the draft model definition
* **returns**:
* a promise resolving with the primary model instance
- **arguments**:
- `Model` - an instance of the draft model definition
- **returns**:
- a promise resolving with the primary model instance

@@ -270,6 +270,6 @@ ### Guards

* **arguments**:
* `model: object` - a model instance
* **returns**:
* `true` for valid model instances, `false` otherwise
- **arguments**:
- `model: object` - a model instance
- **returns**:
- `true` for valid model instances, `false` otherwise

@@ -280,6 +280,6 @@ ```typescript

* **arguments**:
* `model: object` - a model instance
* **returns**:
* In pending state a promise instance resolving with the next model value or a list of values, `false` otherwise
- **arguments**:
- `model: object` - a model instance
- **returns**:
- In pending state a promise instance resolving with the next model value or a list of values, `false` otherwise

@@ -290,7 +290,7 @@ ```typescript

* **arguments**:
* `model` - a model instance
* `propertyName` - a property name of the failed validation defined with `store.value()` method or `null` to return only general error message
* **returns**:
* An error instance or whatever has been thrown, or `false`. When `propertyName` is set, it returns `err.errors[propertyName]` or `false`
- **arguments**:
- `model` - a model instance
- `propertyName` - a property name of the failed validation defined with `store.value()` method or `null` to return only general error message
- **returns**:
- An error instance or whatever has been thrown, or `false`. When `propertyName` is set, it returns `err.errors[propertyName]` or `false`

@@ -303,6 +303,6 @@ ### Ref

* **arguments**:
* `fn` - a function returning the property definition
* **returns**:
* Passed function specially marked, to use the result of the call instead of creating computed property
- **arguments**:
- `fn` - a function returning the property definition
- **returns**:
- Passed function specially marked, to use the result of the call instead of creating computed property

@@ -315,8 +315,8 @@ ### Value

* **arguments**:
* `defaultValue` - `string` or `number` value
* `validate` - a validation function - `validate(val, key, model)`, which should return `false`, error message or throws when validation fails, or a RegExp instance. If omitted, the default validation is used, which fails for empty string and `0`.
* `errorMessage` - optional error message used when validation fails
* **returns**:
* a `String` or `Number` instance
- **arguments**:
- `defaultValue` - `string` or `number` value
- `validate` - a validation function - `validate(val, key, model)`, which should return `false`, error message or throws when validation fails, or a RegExp instance. If omitted, the default validation is used, which fails for empty string and `0`.
- `errorMessage` - optional error message used when validation fails
- **returns**:
- a `String` or `Number` instance

@@ -329,6 +329,6 @@ ### Resolve

* **arguments**:
* `model` - a model instance
* **returns**:
* A promise instance resolving with the latest model value or rejecting with an error
- **arguments**:
- `model` - a model instance
- **returns**:
- A promise instance resolving with the latest model value or rejecting with an error

@@ -343,9 +343,9 @@ ## Router

* **arguments**:
* `views` - a defined component or an array of defined components. You can wrap `views` in a function to avoid using imports from uninitialized ES modules
* `options` - an object with following options:
* `url` - a string base URL used for views without own `url` option, defaults to current URL
* `params` - an array of property names of the element, which are passed to every view as a parameter
* **returns**:
* a hybrid property descriptor, which resolves to an array of elements
- **arguments**:
- `views` - a defined component or an array of defined components. You can wrap `views` in a function to avoid using imports from uninitialized ES modules
- `options` - an object with following options:
- `url` - a string base URL used for views without own `url` option, defaults to current URL
- `params` - an array of property names of the element, which are passed to every view as a parameter
- **returns**:
- a hybrid property descriptor, which resolves to an array of elements

@@ -358,7 +358,7 @@ ### Navigation

* **arguments**:
* `view` - a component definition
* `params` - an object with parameters to pass to the view
* **returns**:
* an URL instance or an empty string
- **arguments**:
- `view` - a component definition
- `params` - an object with parameters to pass to the view
- **returns**:
- an URL instance or an empty string

@@ -369,6 +369,6 @@ ```typescript

* **arguments**:
* `options` - an object with `nested` or `scrollToTop` options, both defaults to `false`
* **returns**:
* an URL instance or an empty string
- **arguments**:
- `options` - an object with `nested` or `scrollToTop` options, both defaults to `false`
- **returns**:
- an URL instance or an empty string

@@ -379,6 +379,6 @@ ```typescript

* **arguments**:
* `params` - an object with parameters to pass to the view
* **returns**:
* an URL instance or an empty string
- **arguments**:
- `params` - an object with parameters to pass to the view
- **returns**:
- an URL instance or an empty string

@@ -389,6 +389,6 @@ ```typescript

* **arguments**:
* `params` - an object with parameters to pass to the view
* **returns**:
* an URL instance or an empty string
- **arguments**:
- `params` - an object with parameters to pass to the view
- **returns**:
- an URL instance or an empty string

@@ -399,7 +399,7 @@ ```typescript

* **arguments**:
* `event` -`click` event from an anchor, or `submit` event from a form element
* `promise` - a promise
* **returns**:
* a chained promise from the arguments
- **arguments**:
- `event` -`click` event from an anchor, or `submit` event from a form element
- `promise` - a promise
- **returns**:
- a chained promise from the arguments

@@ -410,7 +410,7 @@ ```typescript

* **arguments**:
* `views` - a view definition or an array of view definitions
* `options` an optional object with `stack` boolean setting
* **returns**:
* a boolean flag
- **arguments**:
- `views` - a view definition or an array of view definitions
- `options` an optional object with `stack` boolean setting
- **returns**:
- a boolean flag

@@ -423,3 +423,3 @@ ### Debug

* **arguments**:
* `flag` - a boolean flag, defaults to `true`
- **arguments**:
- `flag` - a boolean flag, defaults to `true`
{
"name": "hybrids",
"version": "7.0.5",
"version": "7.0.6",
"description": "A JavaScript framework for creating fully-featured web applications, components libraries, and single web components with unique declarative and functional architecture",

@@ -5,0 +5,0 @@ "type": "module",

import global from "./global.js";
function walk(node, fn, options, items = []) {
function walk(node, fn, options, items = [], host = node) {
Array.from(node.children).forEach((child) => {
const hybrids = child.constructor.hybrids;
if (hybrids && fn(hybrids)) {
if (hybrids && fn(hybrids, host)) {
items.push(child);
if (options.deep && options.nested) {
walk(child, fn, options, items);
walk(child, fn, options, items, host);
}
} else if (options.deep) {
walk(child, fn, options, items);
walk(child, fn, options, items, host);
}

@@ -14,0 +14,0 @@ });

@@ -7,3 +7,3 @@ function walk(node, fn) {

if (hybrids && fn(hybrids)) {
if (hybrids && fn(hybrids, node)) {
return parentElement;

@@ -10,0 +10,0 @@ }

@@ -138,6 +138,9 @@ /* eslint-disable no-use-before-define */

getTimestamp(cachedModel) + result.cache > getCurrentTimestamp();
} else if (result.cache !== true) {
throw TypeError(
`Storage cache property must be a boolean or number: ${typeof result.cache}`,
);
} else {
if (result.cache !== true) {
throw TypeError(
`Storage cache property must be a boolean or number: ${typeof result.cache}`,
);
}
result.validate = (cachedModel) => getTimestamp(cachedModel) !== 1;
}

@@ -937,7 +940,3 @@

if (
validContexts &&
cachedModel &&
(config.storage.cache === true || config.storage.validate(cachedModel))
) {
if (validContexts && cachedModel && config.storage.validate(cachedModel)) {
return cachedModel;

@@ -944,0 +943,0 @@ }

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