Skip to content
Matthew Phillips edited this page Nov 19, 2013 · 4 revisions

This defines an API which allows for steal to build without needing a DOM. Goals of this API are:

  1. Allow steal.build to do its thing without a DOM or DOM substitute.

  2. Needs to be invisible to the end users. Only type authors need a small additional amount of work to implement the API.

In order to achieve this, a module which defines a type needs an alternate implementation that will be run during the build process. The module provides that as part of an options object as the first parameter to the call to steal, which is defined as steal([options,][moduleIdRef...,]definition). So for example, if we have a type foo, it would need 2 implementations

foo.js

steal({
  build: 'steal/view/foo_build'
}, 'can/util', function(can) {
  // definition here
});

foo_build.js

steal({
  map: {
    'can/util': 'can/util/standalone'
  }
}, 'can/util', function(can) {
  // DOM-less implementation
});

In this example foo.js is the base implementation of the foo type. It includes the option build which points to the alternate implementation foo_build. foo_build is the implementation of foo that is not DOM dependent. Since foo requires can/util, foo_build is mapping to a version that doesn't use the DOM.

Clone this wiki locally