Author: pyaschenko
Date: 2010-07-15 12:39:03 -0400 (Thu, 15 Jul 2010)
New Revision: 18085
Modified:
root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
root/core/trunk/impl/src/test/resources/javascript/richfaces-base-component-qunit.js
Log:
removed attachToDom from protected methods
fixed tests
Modified:
root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
===================================================================
---
root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-07-15
11:44:37 UTC (rev 18084)
+++
root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-07-15
16:39:03 UTC (rev 18085)
@@ -25,12 +25,8 @@
var myPrivateMethod = function () {
}
- // create container for protected method's links
- // in this example we link private method as protected
- var $p ={myProtectedMethod: myPrivateMethod};
-
// Extend component class and add protected methods from parent class to our
container
- $p = richfaces.BaseComponent.extend(richfaces.BaseComponent, richfaces.MyComponent,
$p);
+ richfaces.BaseComponent.extend(richfaces.BaseComponent, richfaces.MyComponent);
// define super class link
var $super = richfaces.MyComponent.$super;
@@ -56,27 +52,8 @@
this.id = componentId;
};
- /**
- * <protected> Attach component object to DOM element by component id, DOM
element or jQuery object and returns the element
- *
- * @function
- * @name RichFaces.BaseComponent#attachToDom
- * @param {string|DOMElement|jQuery} source - component id, DOM element or DOM
elements wrapped by jQuery
- *
- * @return {DOMElement}
- * */
- var attachToDom = function(source) {
- source = source || this.id;
- var element = richfaces.getDomElement(source);
- if (element) {
- element["richfaces"] = element["richfaces"] || {};
- element.richfaces.component = this;
- }
- return element;
- }
+ var $p = {};
- var $p = {attachToDom:attachToDom};
-
/**
* Method extends child class prototype with parent prototype
* and return the object with parent's protected methods
@@ -87,6 +64,7 @@
* @return {object}
* */
richfaces.BaseComponent.extend = function (parent, child, h) {
+ h = h || {};
var F = richfaces.blankFunction;
F.prototype = parent.prototype;
child.prototype = new F();
@@ -98,6 +76,7 @@
// create wrapper with protected methods and variables
child.extend = function (_parent, _child, _h) {
+ _h = _h || {};
var _r = jQuery.extend({}, r||h||{}, _h||{});
return richfaces.BaseComponent.extend(_parent, _child, _r);
}
@@ -145,6 +124,25 @@
},
/**
+ * Attach component object to DOM element by component id, DOM element or jQuery
object and returns the element
+ *
+ * @function
+ * @name RichFaces.BaseComponent#attachToDom
+ * @param {string|DOMElement|jQuery} source - component id, DOM element or DOM
elements wrapped by jQuery
+ *
+ * @return {DOMElement}
+ * */
+ attachToDom: function(source) {
+ source = source || this.id;
+ var element = richfaces.getDomElement(source);
+ if (element) {
+ element["richfaces"] = element["richfaces"] || {};
+ element.richfaces.component = this;
+ }
+ return element;
+ },
+
+ /**
* Destroy method. Will be called before remove component from the page
*
* @function
Modified:
root/core/trunk/impl/src/test/resources/javascript/richfaces-base-component-qunit.js
===================================================================
---
root/core/trunk/impl/src/test/resources/javascript/richfaces-base-component-qunit.js 2010-07-15
11:44:37 UTC (rev 18084)
+++
root/core/trunk/impl/src/test/resources/javascript/richfaces-base-component-qunit.js 2010-07-15
16:39:03 UTC (rev 18085)
@@ -8,11 +8,10 @@
var $p ={a:function(){return "hello"}};
$p = richfaces.BaseComponent.extend(richfaces.BaseComponent, MyComponent, $p);
- equals(typeof $p.attachToDom, "function", "ComponentCreation: inherit
protected method from BaseComponent");
var $super = MyComponent.$super;
jQuery.extend(MyComponent.prototype, (function () {
- return { name:"MyComponent", attachToDom:
function(){$p.attachToDom.apply(this,arguments);}}
+ return { name:"MyComponent"}
})());
equals(MyComponent.$super, richfaces.BaseComponent.prototype, "New component:
MyComponent from");
};
@@ -30,7 +29,7 @@
// BaseComponent inheritance
test("RichFaces.BaseComponent inheritance", function () {
- expect(29);
+ expect(26);
createMyComponentClass(RichFaces);
@@ -47,7 +46,6 @@
};
var $p = {b:"b"};
$p = MyComponent.extend(MyComponent, MyComponent2, $p);
- equals(typeof $p.attachToDom, "function", "ComponentCreation: inherit
protected method from BaseComponent");
equals(typeof $p.a, "function", "ComponentCreation: inherit protected
method from MyComponent2");
var $super = MyComponent2.$super;
jQuery.extend(MyComponent2.prototype, (function () {
@@ -71,7 +69,6 @@
};
var $p = {c:"c"};
$p = MyComponent2.extend(MyComponent2, MyComponent3, $p);
- equals(typeof $p.attachToDom, "function", "ComponentCreation: inherit
protected method from BaseComponent");
equals(typeof $p.a, "function", "ComponentCreation: inherit protected
method from MyComponent2");
equals(typeof $p.b, "string", "ComponentCreation: inherit static
protected property from MyComponent3");
var $super = MyComponent3.$super;