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
5
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-view-model

gets or sets the view model of an element

  • 3.2.0
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
decreased by-32.76%
Maintainers
5
Weekly downloads
 
Created
Source

can-view-model

Build Status

Gets or sets the view model of an element

  • can-view-model function

API

can-view-model function

Gets the ViewModel of an element.

canViewModel(element)

Gets the map instance associated with element, creating one as a [can-types.DefaultMap] if it doesn’t already exist, and returns the map.

var vm = canViewModel(element);
  1. element {HTMLElement}: Any element in the DOM.
  • returns {can-map|can-define/map/map|Object}: The ViewModel associated with this element.

canViewModel(element, property)

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 {HTMLElement}: Any element in the DOM.
  2. property {String}: The property to get from the ViewModel.
  • returns {*}: The value of the property on the ViewModel or undefined if the property doesn’t exist.

canViewModel(element, property, value)

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.

canViewModel(element, "foo", "bar");

var foo = canViewModel(element, "foo");

console.log(foo); // -> "bar"
  1. element {HTMLElement}: Any element in the DOM.
  2. property {String}: The property that is being set on the ViewModel.
  3. value {*}: The value being set on the property.
  • returns {HTMLElement}: The element.

Contributing

Making a Build

To make a build of the distributable files into dist/ in the cloned repository run

npm install
node build

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

Keywords

FAQs

Package last updated on 19 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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