You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					40 lines
				
				805 B
			
		
		
			
		
	
	
					40 lines
				
				805 B
			| 
								 
											2 years ago
										 
									 | 
							
								/* eslint-disable */
							 | 
						||
| 
								 | 
							
								var array = require('./array.wxs');
							 | 
						||
| 
								 | 
							
								var object = require('./object.wxs');
							 | 
						||
| 
								 | 
							
								var PREFIX = 'van-';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function join(name, mods) {
							 | 
						||
| 
								 | 
							
								  name = PREFIX + name;
							 | 
						||
| 
								 | 
							
								  mods = mods.map(function(mod) {
							 | 
						||
| 
								 | 
							
								    return name + '--' + mod;
							 | 
						||
| 
								 | 
							
								  });
							 | 
						||
| 
								 | 
							
								  mods.unshift(name);
							 | 
						||
| 
								 | 
							
								  return mods.join(' ');
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function traversing(mods, conf) {
							 | 
						||
| 
								 | 
							
								  if (!conf) {
							 | 
						||
| 
								 | 
							
								    return;
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  if (typeof conf === 'string' || typeof conf === 'number') {
							 | 
						||
| 
								 | 
							
								    mods.push(conf);
							 | 
						||
| 
								 | 
							
								  } else if (array.isArray(conf)) {
							 | 
						||
| 
								 | 
							
								    conf.forEach(function(item) {
							 | 
						||
| 
								 | 
							
								      traversing(mods, item);
							 | 
						||
| 
								 | 
							
								    });
							 | 
						||
| 
								 | 
							
								  } else if (typeof conf === 'object') {
							 | 
						||
| 
								 | 
							
								    object.keys(conf).forEach(function(key) {
							 | 
						||
| 
								 | 
							
								      conf[key] && mods.push(key);
							 | 
						||
| 
								 | 
							
								    });
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function bem(name, conf) {
							 | 
						||
| 
								 | 
							
								  var mods = [];
							 | 
						||
| 
								 | 
							
								  traversing(mods, conf);
							 | 
						||
| 
								 | 
							
								  return join(name, mods);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								module.exports = bem;
							 |