Skip to content

Commit

Permalink
Avoid nesting inside more divs than necessary, which happens to also
Browse files Browse the repository at this point in the history
make styling easier.
  • Loading branch information
Bruno Garcia committed Dec 1, 2010
1 parent 3a9b5f9 commit 980e435
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions projects/tetris/src/tetris/MainMenuScene.js
Expand Up @@ -60,7 +60,7 @@ tetris.MainMenuScene.prototype.load = function () {
tetris.MainMenuScene.prototype.createMainSprite = function (animate) {
var mainSprite = new hydra.Group(hydra.dom.renderDiv(tetris.soy.mainMenu()));
this.addEntity(mainSprite);
var height = mainSprite.element.firstElementChild.offsetHeight;
var height = mainSprite.element.offsetHeight;

if (animate || this.animate) {
mainSprite.setY(-height);
Expand Down Expand Up @@ -122,7 +122,7 @@ tetris.MainMenuScene.prototype.createScoreSprite = function () {
var scoreSprite = new hydra.Group(hydra.dom.renderDiv(
tetris.soy.scoreMenu({scores: scores})));
this.addEntity(scoreSprite);
var height = scoreSprite.element.firstElementChild.offsetHeight;
var height = scoreSprite.element.offsetHeight;

var back = new hydra.Button(scoreSprite.element.querySelector(".button-back"));
back.onTap = function () {
Expand Down
3 changes: 3 additions & 0 deletions src/dom.js
Expand Up @@ -176,5 +176,8 @@ hydra.dom.div = function (className) {
hydra.dom.renderDiv = function (html) {
var div = document.createElement("div");
div.innerHTML = html;
if (div.childElementCount == 1) {
div = div.firstElementChild;
}
return div;
}

0 comments on commit 980e435

Please sign in to comment.