Permalink
Browse files

Merge remote-tracking branch 'iamdustan/run-sugar'

Conflicts:
	CHANGELOG
  • Loading branch information...
2 parents 4092a6d + bd22c5f commit 8104cbd3bd5e1dd66a01d54798fffb8c7c9ee867 @davidaurelio davidaurelio committed Nov 29, 2012
Showing with 29 additions and 3 deletions.
  1. +1 −0 CHANGELOG
  2. +1 −2 src/bootstrapper/player.js
  3. +6 −1 src/renderer/svg/svg.js
  4. +10 −0 test/player-spec.js
  5. +11 −0 test/renderer/svg-spec.js
View
@@ -11,6 +11,7 @@ v0.4.2
* Fixed an issue with KeyframeAnimation where it would trip over certain undefined values
* Fixed a bug in KeyframeAnimation#_fillInProperties where it would refer to the wrong
instance property easingFn (-> easing)
+* Allow for an ID string to be passed to as the first argument to `run`
v0.4.1 / 2012-10-26
-------------------
@@ -73,7 +73,7 @@ function(EventEmitter, RendererController, AssetController, tools, URI, version)
/**
* Loads a bonsai movie and embeds it into a HTML document.
*
- * @param {HTMLElement} node The html element to replace with the movie
+ * @param {HTMLElement|String} node The html element or DOM id to inject the movie into
* @param {string} url The URL to the bonsai script to load
* @param {Number} [options.width] The width of the movie
* @param {Number} [options.height] The height of the movie
@@ -84,7 +84,6 @@ function(EventEmitter, RendererController, AssetController, tools, URI, version)
* @returns {Movie}
*/
run: function(node, url, options) {
-
if (url && typeof url != 'string') {
options = url;
} else {
View
@@ -196,7 +196,7 @@ define([
* The SvgRenderer constructor
*
* @constructor
- * @param {HTMLElement} node The element to append the svg root node to.
+ * @param {HTMLElement|String} node The element or element id to append the svg root node to.
* @param {number} width The width to apply to the svg root node.
* Falsy means 'no width applied'.
* @param {number} height The height to apply to the svg root node.
@@ -208,6 +208,11 @@ define([
* with the framerate.
*/
function SvgRenderer(node, width, height, options) {
+
+ if (typeof node === 'string') {
+ node = document.getElementById(node);
+ }
+
options = options || {};
this.width = width;
this.height = height;
View
@@ -167,6 +167,7 @@ define([
expect(args[3]).toHaveProperties('baseUrl');
});
+
describe('defaultRunnerOptions', function() {
var originalOptions;
beforeEach(function() {
@@ -271,6 +272,15 @@ define([
return player.run(node, options);
})();
+
+ it('passes a string when given a DOM id to the renderer', function () {
+ var node = 'node', width = 100, height = 100, options = { width: width, height: height };
+
+ player.run(node, options);
+
+ expect(MockRendererConstructor).toHaveBeenCalledWith(node, width, height, {});
+ });
+
});
});
View
@@ -13,6 +13,17 @@ define([
return new SvgRenderer(createFakeDomNode(), 1, 1);
}
+ it('should accept a dom id for the node argument', function () {
+ var targetNode = createFakeDomNode();
+ spyOn(targetNode, 'appendChild');
+ spyOn(document, 'getElementById').andReturn(targetNode);
+ var renderer = new SvgRenderer('thing', 1, 1);
+
+ expect(document.getElementById).toHaveBeenCalledWith('thing');
+ expect(targetNode.appendChild).toHaveBeenCalledWith(renderer.svg.rootContainer);
+ });
+
+
describe('allowEventDefaults', function() {
it('should assign the constructor value as property', function() {
expect(new SvgRenderer(createFakeDomNode(), 1, 1, {

0 comments on commit 8104cbd

Please sign in to comment.