Permalink
Browse files

fusejs: Rename fuse.env.Bug/Feature to fuse.env.test and add fuse.env…

….addTest and fuse.env.removeTest methods. [FuseJS LH #44] [jddalton, Joe Gornick, kangax]
  • Loading branch information...
1 parent 14a0ed5 commit 80a497c150879627175a22fcf23458b395d9c2c7 @jdalton jdalton committed Jan 27, 2010
View
@@ -1,3 +1,5 @@
+* Rename fuse.env.Bug/Feature to fuse.env.test and add fuse.env.addTest and fuse.env.removeTest methods. [FuseJS LH #44] [jddalton, Joe Gornick, kangax]
+
* Lowercase the Fuse namespaces and remove the List aliases. [jddalton]
* Add the overlooked reverse(), sort(), and splice() methods to the Fuseboxed Array.prototype. [jddalton]
View
@@ -16,7 +16,7 @@
// XMLHttpRequest doesn't work with local files.
var create = function create() { return false; };
- if (Feature('ACTIVE_X_OBJECT')) {
+ if (envTest('ACTIVE_X_OBJECT')) {
try {
new ActiveXObject('MSXML2.XMLHTTP');
create = function create() {
@@ -9,7 +9,7 @@
(function(plugin) {
var ATTRIBUTE_NODES_PERSIST_ON_CLONED_ELEMENTS =
- Bug('ATTRIBUTE_NODES_PERSIST_ON_CLONED_ELEMENTS');
+ envTest('ATTRIBUTE_NODES_PERSIST_ON_CLONED_ELEMENTS');
plugin.hasAttribute = (function() {
var hasAttribute = function hasAttribute(attribute) {
@@ -184,7 +184,7 @@
// get `href` and other uri attributes
// TODO: Check others attributes like cite, codeBase, lowsrc, and useMap.
- if (Feature('ELEMENT_GET_ATTRIBUTE_IFLAG')) {
+ if (envTest('ELEMENT_GET_ATTRIBUTE_IFLAG')) {
// Exclude `action` attribute because:
// Opera 9.25 will automatically translate the URI from relative to absolute.
// In IE this fix has the reverse effect.
@@ -19,7 +19,7 @@
(function() {
var ELEMENT_TABLE_INNERHTML_INSERTS_TBODY =
- Bug('ELEMENT_TABLE_INNERHTML_INSERTS_TBODY'),
+ envTest('ELEMENT_TABLE_INNERHTML_INSERTS_TBODY'),
FROM_STRING_PARENT_WRAPPERS = (function() {
var T = {
@@ -285,7 +285,7 @@
return getFragmentFromChildNodes(node, cache);
}
- if (Feature('CREATE_ELEMENT_WITH_HTML'))
+ if (envTest('CREATE_ELEMENT_WITH_HTML'))
var create = (function(__create) {
function create(tagName, attributes, context) {
var data, element, id, name, type;
@@ -312,15 +312,15 @@
return create;
})(create);
- if (Feature('ELEMENT_REMOVE_NODE'))
+ if (envTest('ELEMENT_REMOVE_NODE'))
var getFragmentFromChildNodes = function(parentNode, cache) {
// removeNode: removes the parent but keeps the children
var fragment = cache.fragment;
fragment.appendChild(parentNode).removeNode();
return fragment;
};
- if (Feature('DOCUMENT_RANGE'))
+ if (envTest('DOCUMENT_RANGE'))
var getFragmentFromChildNodes = function(parentNode, cache) {
var range = cache.range;
range.selectNodeContents(parentNode);
@@ -347,7 +347,7 @@
dom.extendByTag = extendByTag;
dom.getFragmentFromString =
- Feature('DOCUMENT_RANGE_CREATE_CONTEXTUAL_FRAGMENT')
+ envTest('DOCUMENT_RANGE_CREATE_CONTEXTUAL_FRAGMENT')
? getFromContextualFragment
: getFromDocumentFragment;
})();
@@ -399,11 +399,11 @@
.data = text || '';
}
- if (Feature('ELEMENT_SCRIPT_HAS_TEXT_PROPERTY'))
+ if (envTest('ELEMENT_SCRIPT_HAS_TEXT_PROPERTY'))
return function(element, text) { element.text = text; };
var textNode = fuse._doc.createTextNode('');
- if (!Bug('ELEMENT_SCRIPT_FAILS_TO_EVAL_TEXT'))
+ if (!envTest('ELEMENT_SCRIPT_FAILS_TO_EVAL_TEXT'))
return setScriptText;
textNode = fuse._doc.createComment('');
@@ -418,7 +418,7 @@
element.parentNode.replaceChild(node, element);
}
- if (!Bug('ELEMENT_SCRIPT_FAILS_TO_EVAL_TEXT'))
+ if (!envTest('ELEMENT_SCRIPT_FAILS_TO_EVAL_TEXT'))
return replaceElement;
var T = ELEMENT_INSERT_METHODS,
@@ -582,13 +582,13 @@
var stripped,
element = this.raw || this,
nodeName = getNodeName(element),
- isBuggy = BUGGY[nodeName];
+ envTestgy = BUGGY[nodeName];
if (nodeName === 'SCRIPT') {
setScriptText(element, content);
} else {
// remove children
- if (isBuggy) {
+ if (envTestgy) {
while (element.lastChild)
element.removeChild(element.lastChild);
} else element.innerHTML = '';
@@ -602,7 +602,7 @@
content = Obj.toHTML(content);
stripped = content.stripScripts();
- if (isBuggy) {
+ if (envTestgy) {
if (stripped != '')
element.appendChild(fuse.dom.getFragmentFromString(stripped, element));
}
@@ -617,13 +617,13 @@
};
var BUGGY = { };
- if (Bug('ELEMENT_COLGROUP_INNERHTML_BUGGY'))
+ if (envTest('ELEMENT_COLGROUP_INNERHTML_BUGGY'))
BUGGY.COLGROUP = 1;
- if (Bug('ELEMENT_OPTGROUP_INNERHTML_BUGGY'))
+ if (envTest('ELEMENT_OPTGROUP_INNERHTML_BUGGY'))
BUGGY.OPTGROUP = 1;
- if (Bug('ELEMENT_SELECT_INNERHTML_BUGGY'))
+ if (envTest('ELEMENT_SELECT_INNERHTML_BUGGY'))
BUGGY.SELECT = 1;
- if (Bug('ELEMENT_TABLE_INNERHTML_BUGGY'))
+ if (envTest('ELEMENT_TABLE_INNERHTML_BUGGY'))
BUGGY.TABLE = BUGGY.TBODY = BUGGY.TR = BUGGY.TD =
BUGGY.TFOOT = BUGGY.TH = BUGGY.THEAD = 1;
@@ -683,13 +683,13 @@
plugin.contains.call(element.ownerDocument, element));
};
- if (Feature('ELEMENT_SOURCE_INDEX', 'DOCUMENT_ALL_COLLECTION')) {
+ if (envTest('ELEMENT_SOURCE_INDEX', 'DOCUMENT_ALL_COLLECTION')) {
isDetached = function isDetached() {
var element = this.raw || this;
return element.ownerDocument.all[element.sourceIndex] !== element;
};
}
- if (Feature('ELEMENT_COMPARE_DOCUMENT_POSITION')) {
+ if (envTest('ELEMENT_COMPARE_DOCUMENT_POSITION')) {
isDetached = function isDetached() {
/* DOCUMENT_POSITION_DISCONNECTED = 0x01 */
var element = this.raw || this;
@@ -317,11 +317,11 @@
var getOffset = function(element, ancestor) {
var offsetParent, position, raw, valueT = 0, valueL = 0;
if (BODY_OFFSETS_INHERIT_ITS_MARGINS === null)
- BODY_OFFSETS_INHERIT_ITS_MARGINS = Bug('BODY_OFFSETS_INHERIT_ITS_MARGINS');
+ BODY_OFFSETS_INHERIT_ITS_MARGINS = envTest('BODY_OFFSETS_INHERIT_ITS_MARGINS');
if (ELEMENT_COORD_OFFSETS_DONT_INHERIT_ANCESTOR_BORDER_WIDTH === null)
ELEMENT_COORD_OFFSETS_DONT_INHERIT_ANCESTOR_BORDER_WIDTH =
- Bug('ELEMENT_COORD_OFFSETS_DONT_INHERIT_ANCESTOR_BORDER_WIDTH');
+ envTest('ELEMENT_COORD_OFFSETS_DONT_INHERIT_ANCESTOR_BORDER_WIDTH');
do {
raw = element.raw || element;
@@ -345,7 +345,7 @@
return returnOffset(valueL, valueT);
};
- if (Feature('ELEMENT_BOUNDING_CLIENT_RECT'))
+ if (envTest('ELEMENT_BOUNDING_CLIENT_RECT'))
getOffset = (function(__getOffset) {
return function(element, ancestor) {
var doc, info, rect, raw, root, scrollEl, valueT, valueL;
@@ -431,7 +431,7 @@
return returnOffset(valueL, valueT);
};
- if (Feature('ELEMENT_BOUNDING_CLIENT_RECT')) {
+ if (envTest('ELEMENT_BOUNDING_CLIENT_RECT')) {
getViewportOffset = function getViewportOffset() {
var valueT = 0, valueL = 0;
@@ -51,13 +51,13 @@
return false;
}
- if (Bug('ELEMENT_COMPUTED_STYLE_DEFAULTS_TO_ZERO'))
+ if (envTest('ELEMENT_COMPUTED_STYLE_DEFAULTS_TO_ZERO'))
nullHandlers.push(function(element, name) {
return POSITION_NAMES[name] &&
getComputedStyle(element, 'position') === 'static';
});
- if (Bug('ELEMENT_COMPUTED_STYLE_HEIGHT_IS_ZERO_WHEN_HIDDEN'))
+ if (envTest('ELEMENT_COMPUTED_STYLE_HEIGHT_IS_ZERO_WHEN_HIDDEN'))
nullHandlers.push(function(element, name) {
return DIMENSION_NAMES[name] && getComputedStyle(element, 'display') === 'none';
});
@@ -91,14 +91,14 @@
// fallback for browsers without computedStyle or currentStyle
- if (!Feature('ELEMENT_COMPUTED_STYLE') && !Feature('ELEMENT_CURRENT_STYLE'))
+ if (!envTest('ELEMENT_COMPUTED_STYLE') && !envTest('ELEMENT_CURRENT_STYLE'))
plugin.getStyle = function getStyle(name) {
var result = getValue(this, camelize.call(name));
return result === null ? result : fuse.String(result);
};
// Opera 9.2x
- else if (Bug('ELEMENT_COMPUTED_STYLE_DIMENSIONS_EQUAL_BORDER_BOX'))
+ else if (envTest('ELEMENT_COMPUTED_STYLE_DIMENSIONS_EQUAL_BORDER_BOX'))
plugin.getStyle = function getStyle(name) {
name = camelize.call(name);
var dim, result, element = this.raw || this;
@@ -118,7 +118,7 @@
};
// Firefox, Safari, Opera 9.5+
- else if (Feature('ELEMENT_COMPUTED_STYLE'))
+ else if (envTest('ELEMENT_COMPUTED_STYLE'))
plugin.getStyle = function getStyle(name) {
name = camelize.call(name);
var result, element = this.raw || this;
@@ -298,7 +298,7 @@
return fuse.Number(parseFloat(this.style.opacity));
};
- if (Feature('ELEMENT_COMPUTED_STYLE')) {
+ if (envTest('ELEMENT_COMPUTED_STYLE')) {
getOpacity = function getOpacity() {
var element = this.raw || this,
style = element.ownerDocument.defaultView.getComputedStyle(element, null);
@@ -307,7 +307,7 @@
: element.style.opacity));
};
}
- else if (Feature('ELEMENT_MS_CSS_FILTERS')) {
+ else if (envTest('ELEMENT_MS_CSS_FILTERS')) {
getOpacity = function getOpacity() {
var element = this.raw || this,
currStyle = element.currentStyle || element.style,
@@ -356,7 +356,7 @@
return this;
};
}
- else if (Feature('ELEMENT_MS_CSS_FILTERS')) {
+ else if (envTest('ELEMENT_MS_CSS_FILTERS')) {
setOpacity = function setOpacity(value) {
// strip alpha from filter style
var element = this.raw || this,
@@ -394,15 +394,15 @@
!!(element.offsetHeight || element.offsetWidth);
};
- if (Feature('ELEMENT_COMPUTED_STYLE')) {
+ if (envTest('ELEMENT_COMPUTED_STYLE')) {
isVisible = function isVisible() {
var element = this.raw || this,
compStyle = element.ownerDocument.defaultView.getComputedStyle(element, null);
return !!(compStyle && (element.offsetHeight || element.offsetWidth));
};
}
- if (Bug('TABLE_ELEMENTS_RETAIN_OFFSET_DIMENSIONS_WHEN_HIDDEN')) {
+ if (envTest('TABLE_ELEMENTS_RETAIN_OFFSET_DIMENSIONS_WHEN_HIDDEN')) {
var __isVisible = isVisible;
isVisible = function isVisible() {
@@ -88,7 +88,7 @@
return results;
};
- if (Bug('GET_ELEMENTS_BY_TAG_NAME_RETURNS_COMMENT_NODES')) {
+ if (envTest('GET_ELEMENTS_BY_TAG_NAME_RETURNS_COMMENT_NODES')) {
getDescendants = function getDescendants(selectors) {
var match, node, i = 0, results = NodeList(),
nodes = (this.raw || this).getElementsByTagName('*');
@@ -120,7 +120,7 @@
return false;
};
- if (Feature('ELEMENT_COMPARE_DOCUMENT_POSITION')) {
+ if (envTest('ELEMENT_COMPARE_DOCUMENT_POSITION')) {
contains = function contains(descendant) {
/* DOCUMENT_POSITION_CONTAINS = 0x08 */
if (descendant = fuse.get(descendant)) {
@@ -131,7 +131,7 @@
return false;
};
}
- else if (Feature('ELEMENT_CONTAINS')) {
+ else if (envTest('ELEMENT_CONTAINS')) {
var __contains = contains;
contains = function contains(descendant) {
@@ -164,7 +164,7 @@
return null;
}
- if (Bug('GET_ELEMENTS_BY_TAG_NAME_RETURNS_COMMENT_NODES')) {
+ if (envTest('GET_ELEMENTS_BY_TAG_NAME_RETURNS_COMMENT_NODES')) {
getNth = function(nodes, index) {
var count = 0, i = 0;
while (node = nodes[i++])
@@ -115,7 +115,7 @@
},
getStyle = function(element, styleName) {
- return (getStyle = Feature('ELEMENT_COMPUTED_STYLE')
+ return (getStyle = envTest('ELEMENT_COMPUTED_STYLE')
? function(element, styleName) {
var style = element.ownerDocument.defaultView.getComputedStyle(element, null);
return (style || element.style)[styleName];
@@ -221,7 +221,7 @@
// Ensure the document is not in a frame because
// doScroll() will not throw an error when the document
// is framed. Fallback on document readyState.
- if (!Feature('ELEMENT_ADD_EVENT_LISTENER') && Feature('ELEMENT_DO_SCROLL')) {
+ if (!envTest('ELEMENT_ADD_EVENT_LISTENER') && envTest('ELEMENT_DO_SCROLL')) {
// Avoid a potential browser hang when checking global.top (thanks Rich Dougherty)
// Checking global.frameElement could throw if not accessible.
@@ -242,7 +242,7 @@
}
};
}
- else if (Feature('ELEMENT_ADD_EVENT_LISTENER'))
+ else if (envTest('ELEMENT_ADD_EVENT_LISTENER'))
decoratedDoc.observe('DOMContentLoaded', checkDomLoadedState);
// readystate and poller are used (first one to complete wins)
Oops, something went wrong.

0 comments on commit 80a497c

Please sign in to comment.