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

can-view-model

Package Overview
Dependencies
Maintainers
6
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-view-model - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

CONTRIBUTING.md

12

can-view-model.md

@@ -13,4 +13,10 @@ @module {function} can-view-model can-view-model

var vm = canViewModel(element);
var vm2 = canViewModel("#element2id");
var vm3 = canViewModel($([element3]));
var vm4 = canViewModel(document.querySelectorAll(".element4class"));
```
@param {HTMLElement} element Any element in the DOM.
@param {HTMLElement|String|ArrayLike} element Any element in the DOM, represented by a reference to the element itself, a query selector string, or an Array-like holding the element in its zero index.

@@ -29,3 +35,3 @@ @return {can-map|can-define/map/map|Object} The ViewModel associated with this element.

@param {HTMLElement} element Any element in the DOM.
@param {HTMLElement|String|ArrayLike} element Any element in the DOM, represented by a reference to the element itself, a query selector string, or an Array-like holding the element in its zero index.
@param {String} property The property to get from the ViewModel.

@@ -47,3 +53,3 @@

@param {HTMLElement} element Any element in the DOM.
@param {HTMLElement|String|ArrayLike} element Any element in the DOM, represented by a reference to the element itself, a query selector string, or an Array-like holding the element in its zero index.
@param {String} property The property that is being set on the ViewModel.

@@ -50,0 +56,0 @@ @param {*} value The value being set on the property.

{
"name": "can-view-model",
"version": "3.4.0",
"version": "3.5.0",
"description": "gets or sets the view model of an element",

@@ -23,3 +23,2 @@ "homepage": "http://canjs.com",

"build": "node build.js",
"document": "bit-docs",
"develop": "done-serve --static --develop --port 8080"

@@ -34,11 +33,10 @@ },

"can-namespace": "1.0.0",
"can-reflect": "^1.1.0-pre.1",
"can-simple-map": "^3.3.0-pre.0",
"can-types": "^1.1.0-pre.1",
"can-util": "^3.9.0-pre.4"
"can-reflect": "^1.2.1",
"can-simple-map": "^3.3.0",
"can-types": "^1.1.0",
"can-util": "^3.9.5"
},
"devDependencies": {
"bit-docs": "0.0.7",
"can-define": "^1.3.0-pre.0",
"can-map": "^3.3.0-pre.0",
"can-define": "^1.3.3",
"can-map": "^3.3.1",
"jshint": "^2.9.1",

@@ -48,22 +46,4 @@ "steal": "^1.0.1",

"steal-tools": "^1.0.0",
"testee": "^0.6.1"
},
"bit-docs": {
"dependencies": {
"bit-docs-glob-finder": "^0.0.5",
"bit-docs-dev": "^0.0.3",
"bit-docs-js": "^0.0.3",
"bit-docs-generate-readme": "^0.0.8"
},
"glob": {
"pattern": "**/*.{js,md}",
"ignore": "node_modules/**/*"
},
"readme": {
"apis": [
"can-view-model"
]
},
"parent": "can-view-model"
"testee": "^0.7.0"
}
}
# can-view-model
[![Build Status](https://travis-ci.org/canjs/can-view-model.png?branch=master)](https://travis-ci.org/canjs/can-view-model)
[![Join the chat at https://gitter.im/canjs/canjs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/canjs/canjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/canjs/can-view-model/blob/master/LICENSE.md)
[![npm version](https://badge.fury.io/js/can-view-model.svg)](https://www.npmjs.com/package/can-view-model)
[![Travis build status](https://travis-ci.org/canjs/can-view-model.svg?branch=master)](https://travis-ci.org/canjs/can-view-model)
[![Greenkeeper badge](https://badges.greenkeeper.io/canjs/can-view-model.svg)](https://greenkeeper.io/)
Gets or sets the view model of an element
- <code>[__can-view-model__ function](#can-view-model-function)</code>
- <code>[canViewModel(element)](#canviewmodelelement)</code>
- <code>[canViewModel(element, property)](#canviewmodelelement-property)</code>
- <code>[canViewModel(element, property, value)](#canviewmodelelement-property-value)</code>
## Documentation
## API
Read the [API docs on CanJS.com](https://canjs.com/doc/can-view-model.html).
## Changelog
## <code>__can-view-model__ function</code>
Gets the ViewModel of an [element](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement).
See the [latest releases on GitHub](https://github.com/canjs/can-view-model/releases).
### <code>canViewModel(element)</code>
Gets the map instance associated with **element**, creating one as a [can-types.DefaultMap] if it doesn’t already exist, and returns the map.
```js
var vm = canViewModel(element);
```
1. __element__ <code>{HTMLElement}</code>:
Any element in the DOM.
- __returns__ <code>{can-map|can-define/map/map|Object}</code>:
The ViewModel associated with this element.
### <code>canViewModel(element, property)</code>
Gets the map instance associated with **element**, creating one as a [can-types.DefaultMap] if it doesn’t already exist. Then gets the **property** inside of the ViewModel and returns that.
```
var foo = canViewModel(element, "foo");
console.log(foo); // -> "bar"
```
1. __element__ <code>{HTMLElement}</code>:
Any element in the DOM.
1. __property__ <code>{String}</code>:
The property to get from the ViewModel.
- __returns__ <code>{*}</code>:
The value of the property on the ViewModel or undefined if the property doesn’t exist.
### <code>canViewModel(element, property, value)</code>
Gets the map instance associated with **element**, creating one as a [can-types.DefaultMap] if it doesn’t already exist. Sets the **property** on that map to **value**.
```js
canViewModel(element, "foo", "bar");
var foo = canViewModel(element, "foo");
console.log(foo); // -> "bar"
```
1. __element__ <code>{HTMLElement}</code>:
Any element in the DOM.
1. __property__ <code>{String}</code>:
The property that is being set on the ViewModel.
1. __value__ <code>{*}</code>:
The value being set on the property.
- __returns__ <code>{HTMLElement}</code>:
The element.
## Contributing
### Making a Build
The [contribution guide](https://github.com/canjs/can-view-model/blob/master/CONTRIBUTING.md) has information on getting help, reporting bugs, developing locally, and more.
To make a build of the distributable files into `dist/` in the cloned repository run
## License
```
npm install
node build
```
[MIT](https://github.com/canjs/can-view-model/blob/master/LICENSE.md)
### Running the tests
Tests can run in the browser by opening a web server and visiting the `test.html` page.
Automated tests that run the tests from the command line in Firefox can be run with
```
npm test
```
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