Sizzle.selectors.match/leftMatch
生活随笔
收集整理的這篇文章主要介紹了
Sizzle.selectors.match/leftMatch
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
對象Sizzle.selectors.match/leftMatch中存放了表達式類型和正則的映射,正則用于確定塊表達式的類型,并解析其中的參數。
相關代碼如下:
var Expr = Sizzle.selectors = {match : {ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*/,ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+/,CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*\d+)?))\s*\))?/,POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/} }var origPOS = Expr.match.POS,fescape = function(all, num) {return "\\" + (num - 0 + 1);};for ( var type in Expr.match ) {Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );Expr.leftMatch[ type ] = new RegExp ( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); }我不保證以上代碼的正確性。良心起見,解釋上面代碼的一些難點
總結
以上是生活随笔為你收集整理的Sizzle.selectors.match/leftMatch的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Shell中的while循环
- 下一篇: 理解Node.js的event loop