Permalink
Browse files

mostly tests

  • Loading branch information...
1 parent c4134bd commit 0c3a9e733cc6c3108731b9749e0452111d975bc3 kangax committed May 31, 2008
Showing with 23 additions and 7 deletions.
  1. +5 −3 add_script_add_stylesheet.js
  2. +2 −4 element.methods.js
  3. +5 −0 test/array.extensions.html
  4. +11 −0 test/element.methods.html
@@ -2,12 +2,14 @@
var head = $$('head')[0];
var jsEl = new Element('script', { type: 'text/javascript' });
var cssEl = new Element('link', { type: 'text/css', rel: 'stylesheet' });
- _.addScript = function(url) {
+ Prototype.addScript = function(url, callback) {
jsEl.src = url;
+ jsEl.onload = callback;
head.appendChild(jsEl);
};
- _.addStylesheet = function(url) {
+ Prototype.addStylesheet = function(url, callback) {
cssEl.href = url;
+ cssEl.onload = callback;
head.appendChild(cssEl);
}
-})(Prototype);
+})();
View
@@ -30,10 +30,8 @@ Element.Methods.toTemplate = function(element) {
*
*/
Element.Methods.replaceAttribute = function(element, attr, pattern, replacement) {
- element = $(element);
- return el.writeAttribute(attr, element.readAttribute(attr)
- .replace(new RegExp(pattern), replacement)
- )
+ return Element.writeAttribute(element, attr, element.readAttribute(attr)
+ .replace(new RegExp(pattern), replacement))
};
/**
@@ -21,6 +21,11 @@
testArrayPrototypeSum: function() {
this.assertIdentical(6, [1,2,3].sum());
this.assertIdentical(10, ['1', 2, '3', 4, '', '', '', null, 0].sum());
+ },
+ testArrayPrototypeClone: function() {
+ var arr = [1,2,3];
+ this.assertNotEqual(arr, arr.clone());
+ this.assertEnumEqual([1,2,3], arr.clone());
}
})
</script>
View
@@ -20,6 +20,7 @@
<input type="checkbox" name="dummy_checkbox" value="" checked="checked" id="dummy_checkbox" />
<div id="wrap_dummy">foo bar baz</div>
<div id="contains_dummy">blah // foo \ some other text &copy;</div>
+ <div id="replace_html_dummy">some content...</div>
<script type="text/javascript">
new Test.Unit.Runner({
@@ -45,6 +46,16 @@
this.assert($('contains_dummy').contains('blah'));
this.assert(!$('contains_dummy').contains('fooo'));
this.assert($('contains_dummy').contains(/bla.\s/));
+ },
+ testElementMethodsReplaceHTML: function() {
+ $('replace_html_dummy').replaceHTML(/some/, '_some_');
+ this.assertIdentical('_some_ content...', $('replace_html_dummy').innerHTML);
+ $('replace_html_dummy').replaceHTML(/(\S)/g, '$1 ');
+ this.assertIdentical('_ s o m e _ c o n t e n t . . . ', $('replace_html_dummy').innerHTML);
+ },
+ testElementMethodsReplaceAttribute: function() {
+ $('dummy_input').replaceAttribute('name', /_/g, '-');
+ this.assertIdentical('dummy-input', $('dummy_input').readAttribute('name'));
}
})
</script>

0 comments on commit 0c3a9e7

Please sign in to comment.