解析抽象节点属性

@param {ANode} aNode 抽象节点
@param {string} name 属性名称
@param {string} value 属性值
@param {Object} options 解析参数
@param {Array?} options.delimiters 插值分隔符列表
495059
function integrateAttr(aNode, name, value, options) {
    var prefixIndex = name.indexOf('-');
    var realName;
    var prefix;

    if (prefixIndex > 0) {
        prefix = name.slice(0, prefixIndex);
        realName = name.slice(prefixIndex + 1);
    }

    switch (prefix) {
        case 'on':
            var event = {
                name: realName,
                modifier: {}
            };
            aNode.events.push(event);

            var colonIndex;
            while ((colonIndex = value.indexOf(':')) > 0) {
                var modifier = value.slice(0, colonIndex);

                // eventHandler("dd:aa") 这种情况不能算modifier，需要辨识
                if (!/^[a-z]+$/i.test(modifier)) {
                    break;
                }

                event.modifier[modifier] = true;
                value = value.slice(colonIndex + 1);
            }

            event.expr = parseCall(value, [
                createAccessor([
                    {type: ExprType.STRING, value: '$event'}
                ])
            ]);
            break;

        case 'san':
        case 's':
            parseDirective(aNode, realName, value, options);
            break;

        case 'prop':
            integrateProp(aNode, realName, value, options);
            break;

        case 'var':
            if (!aNode.vars) {
                aNode.vars = [];
            }

            realName = kebab2camel(realName);
            aNode.vars.push({
                name: realName,
                expr: parseExpr(value.replace(/(^\{\{|\}\}$)/g, ''))
            });
            break;

        default:
            integrateProp(aNode, name, value, options);
    }
}
664996
function XName(name) {
        if (TypeUtils.isNullOrUndefined(name)) {
            throw "Name cannot be (null) or (undefined)!";
        }
        name = ('' + name).trim();
        var ns = null;
        var ln = name;
        if (ln.indexOf(':') > -1) {
            var parts = ln.split(':');
            if (2 !== parts.length) {
                throw "Cannot have more than one separator!";
            }
            ns = parts[0].trim();
            ln = parts[1].trim();
        }
        if ('' === ln) {
            throw "Local name cannot be empty!";
        }
        if (null !== ns) {
            ns = ns.trim();
            if ('' === ns) {
                ns = null;
            }
        }
        this._namespace = ns;
        this._localName = ln;
    }
498993
function (aNode, sourceBuffer) {
        if (aNode.textExpr.original) {
            sourceBuffer.joinString(serializeStump('text'));
        }

        if (aNode.textExpr.value != null) {
            sourceBuffer.joinString(aNode.textExpr.segs[0].literal);
        }
        else {
            sourceBuffer.joinExpr(aNode.textExpr);
        }

        if (aNode.textExpr.original) {
            sourceBuffer.joinString(serializeStumpEnd('text'));
        }
    }
251558
function generateRedux(name, options) {
  const config = Config(options);

  let target = path.join(config.srcDir, 'redux', name + '.js');
  if (utils.isFile(target)) {
    console.error(`组件创建失败："${path.relative(config.workDir, target)}" 已经存在`.red);
    process.exit();
  }

  mkdirp.sync(path.dirname(target));

  utils.copyAndReplace(path.join(__dirname, '../templates/redux/index.js'), target, {
    NAME_UPPER_CASE: name.toUpperCase(),
    NAME_LOWER_CASE: name.toLowerCase()
  });
}
8891
function (aNode, sourceBuffer, owner, extra) {
        var dataLiteral = '{}';

        sourceBuffer.addRaw('var $sourceSlots = [];');
        if (aNode.children) {
            var defaultSourceSlots = [];
            var sourceSlotCodes = {};

            each(aNode.children, function (child) {
                var slotBind = !child.textExpr && getANodeProp(child, 'slot');
                if (slotBind) {
                    if (!sourceSlotCodes[slotBind.raw]) {
                        sourceSlotCodes[slotBind.raw] = {
                            children: [],
                            prop: slotBind
                        };
                    }

                    sourceSlotCodes[slotBind.raw].children.push(child);
                }
                else {
                    defaultSourceSlots.push(child);
                }
            });

            if (defaultSourceSlots.length) {
                sourceBuffer.addRaw('$sourceSlots.push([function (componentCtx) {');
                sourceBuffer.addRaw('  var html = "";');
                defaultSourceSlots.forEach(function (child) {
                    aNodeCompiler.compile(child, sourceBuffer, owner);
                });
                sourceBuffer.addRaw('  return html;');
                sourceBuffer.addRaw('}]);');
            }

            for (var key in sourceSlotCodes) {
                var sourceSlotCode = sourceSlotCodes[key];
                sourceBuffer.addRaw('$sourceSlots.push([function (componentCtx) {');
                sourceBuffer.addRaw('  var html = "";');
                sourceBuffer.addRaw(sourceSlotCode.children.forEach(function (child) {
                    aNodeCompiler.compile(child, sourceBuffer, owner);
                }));
                sourceBuffer.addRaw('  return html;');
                sourceBuffer.addRaw('}, ' + compileExprSource.expr(sourceSlotCode.prop.expr) + ']);');
            }
        }


        var givenData = [];
        each(camelComponentBinds(aNode.props), function (prop) {
            postProp(prop);
            givenData.push(
                compileExprSource.stringLiteralize(prop.name)
                + ':'
                + compileExprSource.expr(prop.expr)
            );
        });

        dataLiteral = '{' + givenData.join(',\n') + '}';
        if (aNode.directives.bind) {
            dataLiteral = 'extend('
                + compileExprSource.expr(aNode.directives.bind.value)
                + ', '
                + dataLiteral
                + ')';
        }

        var renderId = compileComponentSource(sourceBuffer, extra.ComponentClass, owner.ssrContextId);
        sourceBuffer.addRaw('html += componentRenderers.' + renderId + '(');
        sourceBuffer.addRaw(dataLiteral + ', true, componentCtx, '
            + stringifier.str(aNode.tagName) + ', $sourceSlots);');
        sourceBuffer.addRaw('$sourceSlots = null;');
    }
1077120
function setOption(name, value) {
  return new Promise(async (resolve, reject) => {
    try {
      await browser.storage.local.set({ [name]: value });
    } catch (error) {
      wappalyzer.log(error.message, 'driver', 'error');

      return reject(error.message);
    }

    return resolve();
  });
}
1372832
function handleField (name, value, options) {
      var serialized
      var length
      var key
      var i

      options = options || { attachment: false }

      if (is(name).a(Object)) {
        for (key in name) {
          if (Object.prototype.hasOwnProperty.call(name, key)) {
            handleField(key, name[key], options)
          }
        }
      } else {
        if (is(value).a(Array)) {
          for (i = 0, length = value.length; i < length; i++) {
            serialized = handleFieldValue(value[i])
            if (serialized) {
              $this.rawField(name, serialized, options)
            }
          }
        } else if (value != null) {
          $this.rawField(name, handleFieldValue(value), options)
        }
      }

      return $this
    }
917072
function (name, value) {
            var result;
            if (arguments.length === 0) {
                /*  return list of keys  */
                result = [];
                for (var key in this.__config)
                    if (_cs.isown(this.__config, key))
                        result.push(key);
            }
            else if (arguments.length === 1 && typeof name === "string") {
                /*  retrieve value  */
                result = this.__config[name];
            }
            else if (arguments.length === 2 && value !== null) {
                /*  set value  */
                result = this.__config[name];
                this.__config[name] = value;
            }
            else if (arguments.length === 2) {
                /*  remove key/value pair  */
                result = this.__config[name];
                delete this.__config[name];
            }
            else
                throw _cs.exception("cfg", "invalid arguments");
            return result;
        }
941724
function (name, value, type) {
    //数据类型存在则检查
    if (type) {
        //字段类型严格验证
        switch (type) {
            case 'integer':
            case 'float':
                if (!lib.isNumber(value)) {
                    return { status: 0, msg: `${name}值类型错误!` };
                }
                break;
            case 'json':
                if (!lib.isJSONObj(value)) {
                    return { status: 0, msg: `${name}值类型错误!` };
                }
                break;
            case 'array':
                if (!lib.isArray(value)) {
                    return { status: 0, msg: `${name}值类型错误!` };
                }
                break;
            case 'string':
            case 'text':
                if (!lib.isString(value)) {
                    return { status: 0, msg: `${name}值类型错误!` };
                }
                break;
            default:
                if (!lib.isString(value)) {
                    return { status: 0, msg: `${name}值类型错误!` };
                }
                break;
        }
    }

    return { status: 1, msg: '' };
}
1143249
function parseNode(attrNode, parsers, context) {
    const attrNames = Object.keys(attrNode);
    const errorContext = context.errorContext;

    Object.keys(parsers).forEach(attrName => {
        const parser = parsers[attrName];

        context.errorContext = ` (option "${attrName}"${errorContext})`;
        removeValue(attrNames, attrName);

        if (attrName in attrNode && parser !== null) {
            attrNode[attrName] = parser(attrNode[attrName], context);
        }
    });

    context.errorContext = errorContext;

    if (attrNames.length > 0) {
        throw new ImplementationError(`Invalid option "${attrNames.join(', ')}"${context.errorContext}`);
    }
}
892697
function() {

                        var newVal = this.options.value();

                        // When given a string, try to extract all the options from it (i.e. "a;b;c;d")
                        if (typeof newVal === 'string') {
                            newVal = newVal.split(this.delimiter);
                            this.isString = true;
                        }
                        // When given something else, try to make it an array and deal with it
                        else if (newVal) {
                            newVal = can.makeArray(newVal);
                        }

                        // Make an object containing all the options passed in for convenient lookup
                        var isSelected = {};
                        can.each(newVal, function(val) {
                            isSelected[val] = true;
                        });

                        // Go through each &lt;option/&gt; element, if it has a value property (its a valid option), then 
                        // set its selected property if it was in the list of vals that were just set.
                        can.each(this.element[0].childNodes, function(option) {
                            if (option.value) {
                                option.selected = !! isSelected[option.value];
                            }

                        });

                    }
571701
function (name, value, schema, options, callback) {

    var err
        , nullable = false
        , valCount = 0;

    // Set default values
    if (options && options.partial !== true) {
        if (schema.hasOwnProperty('default') && value === undefined) {
            if ((_.isString(schema.default) || _.isBoolean(schema.default) || _.isNumber(schema.default)) || (schema.hasOwnProperty('nullable') && schema.nullable === true && _.isNull(schema.default))) {
                value = schema.default;
            }
            else {
                if (_.isFunction(schema.default)) {
                    value = (schema.default)();
                }
                else {
                    err = _.assign({
                        code: 'UnexpectedDefaultValue',
                        'id': name,
                        msg: name + ' default value is faulty. ' + typeof(schema.default) + ' given but not expected'
                    }, err);
                }
            }
        }
    }
    if (value !== undefined) {

        // Check if null value set and is allowed
        if ((schema.hasOwnProperty('nullable') && schema.nullable === true) && value == null) {
            value = null;
        }
        else {
            //Check type
            if (schema.hasOwnProperty('type')) {
                var type = schema.type;
                if (_.isFunction(type) && type.name.toLowerCase()) {
                    type = type.name.toLowerCase();
                }
                var validValue = validationRule.checkType(type, value);
                if (validValue === undefined) {
                    err = _.assign({
                        code: 'UnexpectedType',
                        'id': name,
                        msg: name + ' is unexpected type. ' + typeof(value) + ' given ' + type.toLowerCase() + ' expected'
                    }, err);
                }
                else {
                    value = validValue;
                }
            }

            //Validate single value
            if ((_.isString(value) || _.isBoolean(value) || _.isNumber(value))) {

                //Check minLength
                if (schema.hasOwnProperty('minLength')) {
                    if (validationRule.minLength(schema.minLength, value) == false) {
                        err = _.assign({
                            code: 'MinLengthUnderachieved',
                            'id': name,
                            msg: name + ' length is less than ' + schema.minLength + ' chars'
                        }, err);
                    }
                }

                //Check maxLength
                if (schema.hasOwnProperty('maxLength')) {
                    if (validationRule.maxLength(schema.maxLength, value) == false) {
                        err = _.assign({
                            code: 'MaxLengthExceeded',
                            'id': name,
                            msg: name + ' length is more than ' + schema.maxLength + ' chars'
                        }, err);
                    }
                }


                //Check min
                if (schema.hasOwnProperty('min')) {
                    if (typeof(value) == 'number') {
                        if (validationRule.min(schema.min, value) == false) {
                            err = _.assign({
                                code: 'MinValueUnderachived',
                                'id': name,
                                msg: name + ' value is less than ' + schema.min
                            }, err);
                        }
                    }
                }

                //Check max
                if (schema.hasOwnProperty('max')) {
                    if (typeof(value) == 'number') {
                        if (validationRule.max(schema.max, value) == false) {
                            err = _.assign({
                                code: 'MaxValueExceeded',
                                'id': name,
                                msg: name + ' value is more than ' + schema.max
                            }, err);
                        }
                    }
                }

                //Check allow
                if (schema.hasOwnProperty('allow')) {
                    if (typeof(value) == 'number' || typeof(value) == 'string') {
                        if (validationRule.allow(schema.allow, value) == false) {
                            err = _.assign({
                                code: 'ValueNotAllowed',
                                'id': name,
                                msg: name + ' value \'' + value + '\' is not allowed. Use one of the following values: ' + (schema.allow).join(",")
                            }, err);
                        }
                    }
                }

                //Check deny
                if (schema.hasOwnProperty('deny')) {
                    if (typeof(value) == 'number' || typeof(value) == 'string') {
                        if (validationRule.deny(schema.deny, value) == false) {
                            err = _.assign({
                                code: 'ValueNotAllowed',
                                'id': name,
                                msg: name + ' value \'' + value + '\' is not allowed. Do not use one of the following values: ' + (schema.deny).join(",")
                            });
                        }
                    }
                }

                //Check match
                if (schema.hasOwnProperty('match')) {
                    if (validationRule.match(schema.match, value) == false) {
                        err = _.assign({
                            code: 'PatternMismatch',
                            'id': name,
                            msg: name + ' does not match pattern ' + schema.match + ''
                        }, err);
                    }
                }


                // Convert values
                value = convert.convertValue(schema, value);
            }
        }

        //Validate Array
        if (_.isArray(value)) {
            for (var thisVal in value) {
                valCount++;
                // Check if null value set and is allowed
                if ((schema.hasOwnProperty('nullable') && schema.nullable === true) && value == null) {
                    value = null;
                }
                else {
                    //Check type
                    if (schema.hasOwnProperty('subType')) {
                        if (_.isFunction(schema.subType) && (schema.subType.name).toLowerCase()) {
                            schema.subType = (schema.subType.name).toLowerCase();
                        }
                        var validSubValue = validationRule.checkType(schema.subType, value[thisVal]);
                        if (validSubValue === undefined) {
                            err = _.assign({
                                code: 'UnexpectedType',
                                'id': name,
                                msg: name + '[' + valCount + ']' + ' is unexpected type. ' + typeof(value[thisVal]) + ' given ' + (schema.subType).toLowerCase() + ' expected'
                            }, err);
                        }
                        else {
                            value[thisVal] = validSubValue;
                        }
                    }

                    //Check minLength
                    if (schema.hasOwnProperty('minLength')) {
                        if (validationRule.minLength(schema.minLength, value[thisVal]) == false) {
                            err = _.assign({
                                code: 'MinLengthUnderachieved',
                                'id': name,
                                msg: name + '[' + valCount + ']' + ' length is less than ' + schema.minLength + ' chars'
                            }, err);
                        }
                    }

                    //Check maxLength
                    if (schema.hasOwnProperty('maxLength')) {
                        if (validationRule.maxLength(schema.maxLength, value[thisVal]) == false) {
                            err = _.assign({
                                code: 'MaxLengthExceeded',
                                'id': name,
                                msg: name + '[' + valCount + ']' + ' length is more than ' + schema.maxLength + ' chars'
                            }, err);
                        }
                    }


                    //Check min
                    if (schema.hasOwnProperty('min')) {
                        if (typeof(value) == 'number') {
                            if (validationRule.min(schema.min, value[thisVal]) == false) {
                                err = _.assign({
                                    code: 'MinValueUnderachived',
                                    'id': name,
                                    msg: name + '[' + valCount + ']' + ' value is less than ' + schema.min
                                }, err);
                            }
                        }
                    }

                    //Check max
                    if (schema.hasOwnProperty('max')) {
                        if (typeof(value) == 'number') {
                            if (validationRule.max(schema.max, value[thisVal]) == false) {
                                err = _.assign({
                                    code: 'MaxValueExceeded',
                                    'id': name,
                                    msg: name + '[' + valCount + ']' + ' value is more than ' + schema.max
                                }, err);
                            }
                        }
                    }

                    //Check allow
                    if (schema.hasOwnProperty('allow')) {
                        if (typeof(value) == 'number' || typeof(value[thisVal]) == 'string') {
                            if (validationRule.allow(schema.allow, value[thisVal]) == false) {
                                err = _.assign({
                                    code: 'ValueNotAllowed',
                                    'id': name,
                                    msg: name + '[' + valCount + ']' + ' value \'' + value[thisVal] + '\' is not allowed. Use one of the following values: ' + (schema.allow).join(",")
                                }, err);
                            }
                        }
                    }

                    //Check deny
                    if (schema.hasOwnProperty('deny')) {
                        if (typeof(value) == 'number' || typeof(value[thisVal]) == 'string') {
                            if (validationRule.deny(schema.deny, value[thisVal]) == false) {
                                err = _.assign({
                                    code: 'ValueNotAllowed',
                                    'id': name,
                                    msg: name + '[' + valCount + ']' + ' value \'' + value[thisVal] + '\' is not allowed. Do not use one of the following values: ' + (schema.deny).join(",")
                                });
                            }
                        }
                    }

                    //Check match
                    if (schema.hasOwnProperty('match')) {
                        if (validationRule.match(schema.match, value[thisVal]) == false) {
                            err = _.assign({
                                code: 'PatternMismatch',
                                'id': name,
                                msg: name + '[' + valCount + ']' + ' does not match pattern ' + schema.match + ''
                            }, err);
                        }
                    }
                    // Convert values
                    value[thisVal] = convert.convertValue(schema, value[thisVal]);
                }
            }
        }
    }


    //Check required
    if (schema.hasOwnProperty('required')) {
        if (options && options.partial !== true) {
            if (schema.required == true && (value == undefined || value == "")) {
                if ((schema.hasOwnProperty('public') && schema.public.hasOwnProperty('set') && schema.public.set == false) || (schema.hasOwnProperty('nullable') && schema.nullable === true && _.isNull(value))) {

                }
                else {
                    err = _.assign({
                        code: 'MissingRequiredParameter',
                        id: name,
                        msg: name + ' is required but invalid value or no value given'
                    }, err);
                }
            }
        }
    }

    //Check public
    if (schema.hasOwnProperty('public')) {
        if (schema.public == false || ((schema.public.hasOwnProperty('get') && schema.public.get != true))) {
            value = undefined;
        }
    }
    callback(err, value);
}
1145758
public void appendOptionalUrlAttribute(final String name, final String value) {
		if (value != null) {
			appendUrlAttribute(name, value);
		}
	}
347214
function (sourceBuffer, aNode, owner) {
        // inner content
        if (aNode.tagName === 'textarea') {
            var valueProp = getANodeProp(aNode, 'value');
            if (valueProp) {
                sourceBuffer.joinRaw('escapeHTML('
                    + compileExprSource.expr(valueProp.expr)
                    + ')'
                );
            }

            return;
        }

        var htmlDirective = aNode.directives.html;
        if (htmlDirective) {
            sourceBuffer.joinExpr(htmlDirective.value);
        }
        else {
            /* eslint-disable no-use-before-define */
            each(aNode.children, function (aNodeChild) {
                aNodeCompiler.compile(aNodeChild, sourceBuffer, owner);
            });
            /* eslint-enable no-use-before-define */
        }
    }
1135488
function (name, value) {
			var options = this.options;

			if (value === void 0) {
				return options[name];
			} else {
				options[name] = value;
			}
		}
350307
function (name, value, options) {
            var _member = this.member(name);
            if (_member && _member.setter) {
                _member.setter.call(this, value, options);
            }

            return this;
        }
493157
function defaultElementPropHandler(el, value, name) {
    var propName = HTML_ATTR_PROP_MAP[name] || name;
    value = value == null ? '' : value;
    // input 的 type 是个特殊属性，其实也应该用 setAttribute
    // 但是 type 不应该运行时动态改变，否则会有兼容性问题
    // 所以这里直接就不管了
    if (propName in el) {
        el[propName] = value;
    }
    else {
        el.setAttribute(name, value);
    }

    // attribute 绑定的是 text，所以不会出现 null 的情况，这里无需处理
    // 换句话来说，san 是做不到 attribute 时有时无的
    // if (value == null) {
    //     el.removeAttribute(name);
    // }
}