diff --git a/builder.json b/builder.json index 6d210a5a0ed..b99ccbaeed8 100644 --- a/builder.json +++ b/builder.json @@ -207,11 +207,6 @@ "type": "core", "isDefault": true, "hidden": true - }, - "can/util/domless": { - "name": "can.util.domless", - "type": "plugin", - "hidden": true } }, "types": { diff --git a/util/array/makeArray.js b/util/array/makeArray.js index 32d8f444214..c90f99ba6af 100644 --- a/util/array/makeArray.js +++ b/util/array/makeArray.js @@ -1,4 +1,4 @@ -steal('./each.js', function (can) { +steal('./each.js', function () { can.makeArray = function (arr) { var ret = []; can.each(arr, function (a, i) { diff --git a/util/attr/attr.js b/util/attr/attr.js index ddfd66967ba..8d3bba4758a 100644 --- a/util/attr/attr.js +++ b/util/attr/attr.js @@ -7,14 +7,14 @@ steal("can/util/can.js", function (can) { // Acts as a polyfill for setImmediate which only works in IE 10+. Needed to make // the triggering of `attributes` event async. - var setImmediate = (typeof window !== "undefined" && window.setImmediate) || function (cb) { + var setImmediate = window.setImmediate || function (cb) { return setTimeout(cb, 0); }, attr = { // This property lets us know if the browser supports mutation observers. // If they are supported then that will be setup in can/util/jquery and those native events will be used to inform observers of attribute changes. // Otherwise this module handles triggering an `attributes` event on the element. - MutationObserver: typeof window !== "undefined" && (window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver), + MutationObserver: window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, /** * @property {Object.} can.view.attr.map @@ -161,19 +161,15 @@ steal("can/util/can.js", function (can) { // Checks if an element contains an attribute. // For browsers that support `hasAttribute`, creates a function that calls hasAttribute, otherwise creates a function that uses `getAttribute` to check that the attribute is not null. has: (function () { - if(typeof document !== "undefined") { - var el = document.createElement('div'); - if (el.hasAttribute) { - return function (el, name) { - return el.hasAttribute(name); - }; - } else { - return function (el, name) { - return el.getAttribute(name) !== null; - }; - } + var el = document.createElement('div'); + if (el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; } else { - return function() {}; + return function (el, name) { + return el.getAttribute(name) !== null; + }; } })() }; diff --git a/util/can.js b/util/can.js index f9ca0701952..335dc7da10b 100644 --- a/util/can.js +++ b/util/can.js @@ -1,13 +1,8 @@ steal(function () { /* global GLOBALCAN */ - var can; - if (typeof window !== 'undefined') { - can = window.can || {}; - if(typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { - window.can = can; - } - } else { - can = {}; + var can = window.can || {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + window.can = can; } // An empty function useful for where you need a dummy callback. diff --git a/util/domless/domless.js b/util/domless/domless.js deleted file mode 100644 index bda43673dff..00000000000 --- a/util/domless/domless.js +++ /dev/null @@ -1,126 +0,0 @@ -steal('can/util/can.js', 'can/util/attr', 'can/util/array/each.js', 'can/util/array/makeArray.js', function(can, attr) { - - var core_trim = String.prototype.trim; - var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; - - function likeArray(obj) { - return typeof obj.length === 'number'; - } - - function flatten(array) { - return array.length > 0 ? Array.prototype.concat.apply([], array) : array; - } - - can.isFunction = (function(){ - if(typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function'){ - return function (value) { - return Object.prototype.toString.call(value) === '[object Function]'; - }; - } else { - return function (value) { - return typeof value === 'function'; - }; - } - })(); - - can.trim = core_trim && !core_trim.call('\uFEFF\xA0') ? - function (text) { - return text == null ? '' : core_trim.call(text); - } : - // Otherwise use our own trimming functionality - function (text) { - return text == null ? '' : ( text + '' ).replace(rtrim, ''); - }; - - // This extend() function is ruthlessly and shamelessly stolen from - // jQuery 1.8.2:, lines 291-353. - can.extend = function () { - /*jshint maxdepth:6 */ - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if (typeof target === "boolean") { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if (typeof target !== "object" && !can.isFunction(target)) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if (length === i) { - target = this; - --i; - } - - for (; i < length; i++) { - // Only deal with non-null/undefined values - if ((options = arguments[ i ]) != null) { - // Extend the base object - for (name in options) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if (target === copy) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if (deep && copy && ( can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)) )) { - if (copyIsArray) { - copyIsArray = false; - clone = src && can.isArray(src) ? src : []; - - } else { - clone = src && can.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = can.extend(deep, clone, copy); - - // Don't bring in undefined values - } else if (copy !== undefined) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; - }; - - can.map = function (elements, callback) { - var values = [], - putValue = function (val, index) { - var value = callback(val, index); - if (value != null) { - values.push(value); - } - }; - if (likeArray(elements)) { - for (var i = 0, l = elements.length; i < l; i++) { - putValue(elements[i], i); - } - } else { - for (var key in elements) { - putValue(elements[key], key); - } - } - return flatten(values); - }; - - can.attr = attr; - - return can; - -}); \ No newline at end of file diff --git a/view/callbacks/callbacks.js b/view/callbacks/callbacks.js index 57c955abe88..3edbf225cc4 100644 --- a/view/callbacks/callbacks.js +++ b/view/callbacks/callbacks.js @@ -34,7 +34,7 @@ steal("can/util", "can/view",function(can){ var tag = can.view.tag = function (tagName, tagHandler) { if(tagHandler) { // if we have html5shive ... re-generate - if (typeof window !== "undefined" && window.html5) { + if (window.html5) { window.html5.elements += " " + tagName; window.html5.shivDocument(); } diff --git a/view/elements.js b/view/elements.js index dbb571eb46f..63400ed3081 100644 --- a/view/elements.js +++ b/view/elements.js @@ -13,7 +13,7 @@ steal('can/util', "can/view",function (can) { */ var elements = { tagToContentPropMap: { - option: ( typeof document !=="undefined" && "textContent" in document.createElement("option") ) ? "textContent" : "innerText", + option: 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', textarea: 'value' }, /** diff --git a/view/mustache/mustache.js b/view/mustache/mustache.js index 38f480fa43f..568e748edf3 100644 --- a/view/mustache/mustache.js +++ b/view/mustache/mustache.js @@ -116,10 +116,7 @@ steal('can/util', * @add can.Mustache */ // Put Mustache on the `can` object. - can.Mustache = Mustache; - if(typeof window !== "undefined") { - window.Mustache = Mustache; - } + can.Mustache = window.Mustache = Mustache; /** * @prototype diff --git a/view/parser/parser.js b/view/parser/parser.js index e8f284ebb0e..e4244d297e0 100644 --- a/view/parser/parser.js +++ b/view/parser/parser.js @@ -1,5 +1,5 @@ /* jshint maxdepth:7*/ -steal("can/view", function(can){ +steal("can/view", function(){ function makeMap(str){ diff --git a/view/view.js b/view/view.js index de7c5ccf557..83538f7a3a4 100644 --- a/view/view.js +++ b/view/view.js @@ -96,7 +96,7 @@ steal('can/util', function (can) { // You should only be using `//` if you are using an AMD loader like `steal` or `require` (not almond). if (url.match(/^\/\//)) { url = url.substr(2); - url = ( typeof window === "undefined" || ! window.steal ) ? + url = !window.steal ? url : steal.config() .root.mapJoin("" + steal.id(url)); @@ -382,7 +382,7 @@ steal('can/util', function (can) { // _removed if not used as a steal module_ //!steal-remove-start - if ( typeof window !== "undefined" && window.steal ) { + if (window.steal) { steal.type(info.suffix + " view js", function (options, success, error) { var type = $view.types["." + options.type], id = $view.toId(options.id + ''); @@ -711,7 +711,7 @@ steal('can/util', function (can) { // _removed if not used as a steal module_ //!steal-remove-start - if ( typeof window !== "undefined" && window.steal ) { + if (window.steal) { //when being used as a steal module, add a new type for 'view' that runs // `can.view.preloadStringRenderer` with the loaded string/text for the dependency. steal.type("view js", function (options, success, error) {