欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

seajs-css less 加载_html/css_WEB-ITnose

程序员文章站 2022-05-21 11:32:35
...
(function(){    /**     * util-request.js - The utilities for requesting script and style files     * ref: tests/research/load-js-css/test.html     */    function isType(type) {        return function(obj) {            return {}.toString.call(obj) == "[object " + type + "]"        }    }    var isString = isType("String")    var doc = document    var head = doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement    var baseElement = head.getElementsByTagName("base")[0]    var IS_CSS_RE = /\.css(?:\?|$)/i    var IS_LESS_RE = /\.less(?:\?|$)/i    var currentlyAddingScript    var interactiveScript// `onload` event is not supported in WebKit  "a/b/"// ref: http://jsperf.com/regex-vs-split/2    function dirname(path) {        return path.match(DIRNAME_RE)[0]    }// Canonicalize a path// realpath("http://test.com/a//./b/../c") ==> "http://test.com/a/c"    function realpath(path) {        // /a/b/./c/./d ==> /a/b/c/d        path = path.replace(DOT_RE, "/")        /*         @author wh1100717         a//b/c ==> a/b/c         a///b/////c ==> a/b/c         DOUBLE_DOT_RE matches a/b/c//../d path correctly only if replace // with / first         */        path = path.replace(MULTI_SLASH_RE, "$1/")        // a/b/c/../../d  ==>  a/b/../d  ==>  a/d        while (path.match(DOUBLE_DOT_RE)) {            path = path.replace(DOUBLE_DOT_RE, "/")        }        return path    }// Normalize an id// normalize("path/to/a") ==> "path/to/a.js"// NOTICE: substring is faster than negative slice and RegExp    function normalize(path) {        var last = path.length - 1        var lastC = path.charAt(last)        // If the uri ends with `#`, just return it without '#'        if (lastC === "#") {            return path.substring(0, last)        }        return (path.substring(last - 2) === ".js" ||            path.indexOf("?") > 0 ||            path.substring(last - 3) === ".css" ||            path.substring(last - 4) === ".less" ||            lastC === "/") ? path : path + ".js"    }    var PATHS_RE = /^([^/:]+)(\/.+)$/    var VARS_RE = /{([^{]+)}/g    function parseAlias(id) {        var alias = data.alias        return alias && isString(alias[id]) ? alias[id] : id    }    function parsePaths(id) {        var paths = data.paths        var m        if (paths && (m = id.match(PATHS_RE)) && isString(paths[m[1]])) {            id = paths[m[1]] + m[2]        }        return id    }    function parseVars(id) {        var vars = data.vars        if (vars && id.indexOf("{") > -1) {            id = id.replace(VARS_RE, function(m, key) {                return isString(vars[key]) ? vars[key] : m            })        }        return id    }    function parseMap(uri) {        var map = data.map        var ret = uri        if (map) {            for (var i = 0, len = map.length; i