Sha256: a7b6ef59753ef96d59e9cfd030ecdf9b5ef0300038a1062e2ae6370773ea3f30

Contents?: true

Size: 1.81 KB

Versions: 30

Compression:

Stored size: 1.81 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Apple Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/*global module test equals context ok same */

// ..........................................................
// createChildViews()
// 
var view, parentDom, childDom, layerId ;
module("SC.View#findLayerInParentLayer", {
  setup: function() {
    
    layerId = 'foo-123';
    
    // manually construct a test layer.  next childDom a few layers deep
    childDom = document.createElement('div');
    SC.$(childDom).attr('id', layerId);
    
    var intermediate = document.createElement('div');
    intermediate.appendChild(childDom);
    
    parentDom = document.createElement('div');
    parentDom.appendChild(intermediate);
    intermediate = null;
    
    
    // setup view w/ layerId
    view = SC.View.create({ layerId: layerId });
  },
  
  teardown: function() {
    view = parentDom = childDom = layerId = null;
  }
});

test("discovers layer by finding element with matching layerId - when DOM is in document already", function() {
  document.body.appendChild(parentDom);
  equals(view.findLayerInParentLayer(parentDom), childDom, 'should find childDom');
  document.body.removeChild(parentDom); // cleanup or else next test may fail
});

test("discovers layer by finding element with matching layerId - when parent DOM is NOT in document", function() {
  if(parentDom.parentNode) equals(parentDom.parentNode.nodeType, 11, 'precond - NOT in parent doc');
  else equals(parentDom.parentNode, null, 'precond - NOT in parent doc');
  equals(view.findLayerInParentLayer(parentDom), childDom, 'found childDom');
});

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
sproutcore-1.9.2 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.9.1 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.9.0 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.8.2.1 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.8.1 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.8.0 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.1 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0-java lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.rc.2-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.rc.2 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.rc.2-java lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.rc.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.rc.1 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.rc.1-java lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js
sproutcore-1.6.0.beta.3-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/findLayerInParentLayer.js