File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -232,19 +232,39 @@ export class EngineConfig {
232232 this . config = config || { } ;
233233 }
234234
235+ /**
236+ * 判断指定 key 是否有值
237+ * @param key
238+ * @returns
239+ */
235240 has ( key : string ) : boolean {
236241 return this . config [ key ] !== undefined ;
237242 }
238243
244+ /**
245+ * 获取指定 key 的值
246+ * @param key
247+ * @param defaultValue
248+ * @returns
249+ */
239250 get ( key : string , defaultValue ?: any ) : any {
240251 return lodashGet ( this . config , key , defaultValue ) ;
241252 }
242253
254+ /**
255+ * 设置指定 key 的值
256+ * @param key
257+ * @param value
258+ */
243259 set ( key : string , value : any ) {
244260 this . config [ key ] = value ;
245261 this . notifyGot ( key ) ;
246262 }
247263
264+ /**
265+ * 批量设值,set 的对象版本
266+ * @param config
267+ */
248268 setConfig ( config : { [ key : string ] : any } ) {
249269 if ( config ) {
250270 Object . keys ( config ) . forEach ( ( key ) => {
@@ -281,6 +301,12 @@ export class EngineConfig {
281301 }
282302 }
283303
304+ /**
305+ * 获取指定 key 的值,若此时还未赋值,则等待,若已有值,则直接返回值
306+ * 注:此函数返回 Promise 实例,只会执行(fullfill)一次
307+ * @param key
308+ * @returns
309+ */
284310 onceGot ( key : string ) : Promise < any > {
285311 const val = this . config [ key ] ;
286312 if ( val !== undefined ) {
@@ -291,6 +317,12 @@ export class EngineConfig {
291317 } ) ;
292318 }
293319
320+ /**
321+ * 获取指定 key 的值,函数回调模式,若多次被赋值,回调会被多次调用
322+ * @param key
323+ * @param fn
324+ * @returns
325+ */
294326 onGot ( key : string , fn : ( data : any ) => void ) : ( ) => void {
295327 const val = this . config ?. [ key ] ;
296328 if ( val !== undefined ) {
Original file line number Diff line number Diff line change @@ -348,7 +348,7 @@ export default class Node {
348348 * @param useMutator
349349 */
350350 insertBefore ( node : Node , ref ?: Node | undefined , useMutator ?: boolean ) {
351- this [ nodeSymbol ] . insertBefore ( node [ nodeSymbol ] , ref ?. [ nodeSymbol ] , useMutator ) ;
351+ this [ nodeSymbol ] . insertBefore ( node [ nodeSymbol ] || node , ref ?. [ nodeSymbol ] , useMutator ) ;
352352 }
353353
354354 /**
@@ -358,7 +358,7 @@ export default class Node {
358358 * @param useMutator
359359 */
360360 insertAfter ( node : Node , ref ?: Node | undefined , useMutator ?: boolean ) {
361- this [ nodeSymbol ] . insertAfter ( node [ nodeSymbol ] , ref ?. [ nodeSymbol ] , useMutator ) ;
361+ this [ nodeSymbol ] . insertAfter ( node [ nodeSymbol ] || node , ref ?. [ nodeSymbol ] , useMutator ) ;
362362 }
363363
364364 /**
You can’t perform that action at this time.
0 commit comments