lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (quoteSmart, tagName) {
            var start, state, done, quote, ch, end, comment, mCursor = this.cursor, mPage = this.page;
            start = mCursor.position;
            state = 0;
            done = false;
            quote = '';
            comment = false;
            while (!done) {
                ch = mPage.getChar(mCursor);
                switch (state) {
                case 0:
                    // prior to ETAGO
                    switch (ch) {
                    case -1:
                        done = true;
                        break;
                    case '\'':
                        if (quoteSmart && !comment) {
                            if ('' === quote) {
                                quote = '\'';    // enter quoted state
                            } else // enter quoted state
                            if ('\'' === quote) {
                                quote = '';    // exit quoted state
                            }
                        }
                        // exit quoted state
                        break;
                    case '"':
                        if (quoteSmart && !comment) {
                            if ('' === quote) {
                                quote = '"';    // enter quoted state
                            } else // enter quoted state
                            if ('"' === quote) {
                                quote = '';    // exit quoted state
                            }
                        }
                        // exit quoted state
                        break;
                    case '\\':
                        if (quoteSmart) {
                            if ('' !== quote) {
                                ch = mPage.getChar(mCursor);    // try to consume escaped character
                                // try to consume escaped character
                                if (NEGATIVE_1 === ch) {
                                    done = true;
                                } else if (ch !== '\\' && ch !== quote) {
                                    // unconsume char if character was not an escapable char.
                                    mPage.ungetChar(mCursor);
                                }
                            }
                        }
                        break;
                    case '/':
                        if (quoteSmart) {
                            if ('' === quote) {
                                // handle multiline and double slash comments (with a quote)
                                ch = mPage.getChar(mCursor);
                                if (NEGATIVE_1 === ch) {
                                    done = true;
                                } else if ('/' === ch) {
                                    comment = true;
                                } else if ('*' === ch) {
                                    do {
                                        do {
                                            ch = mPage.getChar(mCursor);
                                        } while (NEGATIVE_1 !== ch && '*' !== ch);
                                        ch = mPage.getChar(mCursor);
                                        if (ch === '*') {
                                            mPage.ungetChar(mCursor);
                                        }
                                    } while (NEGATIVE_1 !== ch && '/' !== ch);
                                } else {
                                    mPage.ungetChar(mCursor);
                                }
                            }
                        }
                        break;
                    case '\n':
                        comment = false;
                        break;
                    case '<':
                        if (quoteSmart) {
                            if ('' === quote) {
                                state = 1;
                            }
                        } else {
                            state = 1;
                        }
                        break;
                    default:
                        break;
                    }
                    break;
                case 1:
                    // <
                    switch (ch) {
                    case -1:
                        done = true;
                        break;
                    case '/':
                        // tagName = 'textarea'
                        // <textarea><div></div></textarea>
                        /*
                             8.1.2.6 Restrictions on the contents of raw text and RCDATA elements

                             The text in raw text and RCDATA elements must not contain any occurrences
                             of the string '</' (U+003C LESS-THAN SIGN, U+002F SOLIDUS)
                             followed by characters that case-insensitively match the tag name of the element
                             followed by one of U+0009 CHARACTER TABULATION (tab),
                             U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR),
                             U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or U+002F SOLIDUS (/).
                             */
                        if (!tagName || mPage.getText(mCursor.position, mCursor.position + tagName.length) === tagName && !mPage.getText(mCursor.position + tagName.length, mCursor.position + tagName.length + 1).match(/\w/)) {
                            state = 2;
                        } else {
                            state = 0;
                        }
                        break;
                    case '!':
                        ch = mPage.getChar(mCursor);
                        if (NEGATIVE_1 === ch) {
                            done = true;
                        } else if ('-' === ch) {
                            ch = mPage.getChar(mCursor);
                            if (NEGATIVE_1 === ch) {
                                done = true;
                            } else if ('-' === ch) {
                                state = 3;
                            } else {
                                state = 0;
                            }
                        } else {
                            state = 0;
                        }
                        break;
                    default:
                        state = 0;
                        break;
                    }
                    break;
                case 2:
                    // </
                    comment = false;
                    if (NEGATIVE_1 === ch) {
                        done = true;
                    } else if (Utils.isLetter(ch)) {
                        // 严格 parser 遇到 </x lexer 立即结束
                        // 浏览器实现更复杂点，可能 lexer 和 parser 混合了
                        done = true;    // back up to the start of ETAGO
                        // back up to the start of ETAGO
                        mPage.ungetChar(mCursor);
                        mPage.ungetChar(mCursor);
                        mPage.ungetChar(mCursor);
                    } else {
                        state = 0;
                    }
                    break;
                case 3:
                    // <!
                    comment = false;
                    if (NEGATIVE_1 === ch) {
                        done = true;
                    } else if ('-' === ch) {
                        ch = mPage.getChar(mCursor);
                        if (NEGATIVE_1 === ch) {
                            done = true;
                        } else if ('-' === ch) {
                            ch = mPage.getChar(mCursor);
                            if (NEGATIVE_1 === ch) {
                                done = true;
                            } else if ('>' === ch) {
                                // <!----> <!-->
                                state = 0;
                            } else {
                                // retreat twice , still begin to check -->
                                mPage.ungetChar(mCursor);
                                mPage.ungetChar(mCursor);
                            }
                        } else {
                            // retreat once , still begin to check
                            mPage.ungetChar(mCursor);
                        }
                    }    // eat comment
                    // eat comment
                    break;
                default:
                    throw new Error('unexpected ' + state);
                }
            }
            end = mCursor.position;
            return this.makeCData(start, end);
        }
function (quoteSmart, tagName) {
            var start, state, done, quote, ch, end, comment, mCursor = this.cursor, mPage = this.page;
            start = mCursor.position;
            state = 0;
            done = false;
            quote = '';
            comment = false;
            while (!done) {
                ch = mPage.getChar(mCursor);
                switch (state) {
                case 0:
                    // prior to ETAGO
                    switch (ch) {
                    case -1:
                        done = true;
                        break;
                    case '\'':
                        if (quoteSmart && !comment) {
                            if ('' === quote) {
                                quote = '\'';    // enter quoted state
                            } else // enter quoted state
                            if ('\'' === quote) {
                                quote = '';    // exit quoted state
                            }
                        }
                        // exit quoted state
                        break;
                    case '"':
                        if (quoteSmart && !comment) {
                            if ('' === quote) {
                                quote = '"';    // enter quoted state
                            } else // enter quoted state
                            if ('"' === quote) {
                                quote = '';    // exit quoted state
                            }
                        }
                        // exit quoted state
                        break;
                    case '\\':
                        if (quoteSmart) {
                            if ('' !== quote) {
                                ch = mPage.getChar(mCursor);    // try to consume escaped character
                                // try to consume escaped character
                                if (NEGATIVE_1 === ch) {
                                    done = true;
                                } else if (ch !== '\\' && ch !== quote) {
                                    // unconsume char if character was not an escapable char.
                                    mPage.ungetChar(mCursor);
                                }
                            }
                        }
                        break;
                    case '/':
                        if (quoteSmart) {
                            if ('' === quote) {
                                // handle multiline and double slash comments (with a quote)
                                ch = mPage.getChar(mCursor);
                                if (NEGATIVE_1 === ch) {
                                    done = true;
                                } else if ('/' === ch) {
                                    comment = true;
                                } else if ('*' === ch) {
                                    do {
                                        do {
                                            ch = mPage.getChar(mCursor);
                                        } while (NEGATIVE_1 !== ch && '*' !== ch);
                                        ch = mPage.getChar(mCursor);
                                        if (ch === '*') {
                                            mPage.ungetChar(mCursor);
                                        }
                                    } while (NEGATIVE_1 !== ch && '/' !== ch);
                                } else {
                                    mPage.ungetChar(mCursor);
                                }
                            }
                        }
                        break;
                    case '\n':
                        comment = false;
                        break;
                    case '<':
                        if (quoteSmart) {
                            if ('' === quote) {
                                state = 1;
                            }
                        } else {
                            state = 1;
                        }
                        break;
                    default:
                        break;
                    }
                    break;
                case 1:
                    // <
                    switch (ch) {
                    case -1:
                        done = true;
                        break;
                    case '/':
                        // tagName = 'textarea'
                        // <textarea><div></div></textarea>
                        /*
                             8.1.2.6 Restrictions on the contents of raw text and RCDATA elements

                             The text in raw text and RCDATA elements must not contain any occurrences
                             of the string '</' (U+003C LESS-THAN SIGN, U+002F SOLIDUS)
                             followed by characters that case-insensitively match the tag name of the element
                             followed by one of U+0009 CHARACTER TABULATION (tab),
                             U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR),
                             U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or U+002F SOLIDUS (/).
                             */
                        if (!tagName || mPage.getText(mCursor.position, mCursor.position + tagName.length) === tagName && !mPage.getText(mCursor.position + tagName.length, mCursor.position + tagName.length + 1).match(/\w/)) {
                            state = 2;
                        } else {
                            state = 0;
                        }
                        break;
                    case '!':
                        ch = mPage.getChar(mCursor);
                        if (NEGATIVE_1 === ch) {
                            done = true;
                        } else if ('-' === ch) {
                            ch = mPage.getChar(mCursor);
                            if (NEGATIVE_1 === ch) {
                                done = true;
                            } else if ('-' === ch) {
                                state = 3;
                            } else {
                                state = 0;
                            }
                        } else {
                            state = 0;
                        }
                        break;
                    default:
                        state = 0;
                        break;
                    }
                    break;
                case 2:
                    // </
                    comment = false;
                    if (NEGATIVE_1 === ch) {
                        done = true;
                    } else if (Utils.isLetter(ch)) {
                        // 严格 parser 遇到 </x lexer 立即结束
                        // 浏览器实现更复杂点，可能 lexer 和 parser 混合了
                        done = true;    // back up to the start of ETAGO
                        // back up to the start of ETAGO
                        mPage.ungetChar(mCursor);
                        mPage.ungetChar(mCursor);
                        mPage.ungetChar(mCursor);
                    } else {
                        state = 0;
                    }
                    break;
                case 3:
                    // <!
                    comment = false;
                    if (NEGATIVE_1 === ch) {
                        done = true;
                    } else if ('-' === ch) {
                        ch = mPage.getChar(mCursor);
                        if (NEGATIVE_1 === ch) {
                            done = true;
                        } else if ('-' === ch) {
                            ch = mPage.getChar(mCursor);
                            if (NEGATIVE_1 === ch) {
                                done = true;
                            } else if ('>' === ch) {
                                // <!----> <!-->
                                state = 0;
                            } else {
                                // retreat twice , still begin to check -->
                                mPage.ungetChar(mCursor);
                                mPage.ungetChar(mCursor);
                            }
                        } else {
                            // retreat once , still begin to check
                            mPage.ungetChar(mCursor);
                        }
                    }    // eat comment
                    // eat comment
                    break;
                default:
                    throw new Error('unexpected ' + state);
                }
            }
            end = mCursor.position;
            return this.makeCData(start, end);
        }
function ( quoteSmart , tagName ) { var start , state , done , quote , ch , end , comment , mCursor = this . cursor , mPage = this . page ; start = mCursor . position ; state = 0 ; done = false ; quote = '' ; comment = false ; while ( ! done ) { ch = mPage . getChar ( mCursor ) ; switch ( state ) { case 0 : // prior to ETAGO switch ( ch ) { case - 1 : done = true ; break ; case '\'' : if ( quoteSmart && ! comment ) { if ( '' === quote ) { quote = '\'' ; // enter quoted state } else // enter quoted state if ( '\'' === quote ) { quote = '' ; // exit quoted state } } // exit quoted state break ; case '"' : if ( quoteSmart && ! comment ) { if ( '' === quote ) { quote = '"' ; // enter quoted state } else // enter quoted state if ( '"' === quote ) { quote = '' ; // exit quoted state } } // exit quoted state break ; case '\\' : if ( quoteSmart ) { if ( '' !== quote ) { ch = mPage . getChar ( mCursor ) ; // try to consume escaped character // try to consume escaped character if ( NEGATIVE_1 === ch ) { done = true ; } else if ( ch !== '\\' && ch !== quote ) { // unconsume char if character was not an escapable char. mPage . ungetChar ( mCursor ) ; } } } break ; case '/' : if ( quoteSmart ) { if ( '' === quote ) { // handle multiline and double slash comments (with a quote) ch = mPage . getChar ( mCursor ) ; if ( NEGATIVE_1 === ch ) { done = true ; } else if ( '/' === ch ) { comment = true ; } else if ( '*' === ch ) { do { do { ch = mPage . getChar ( mCursor ) ; } while ( NEGATIVE_1 !== ch && '*' !== ch ) ; ch = mPage . getChar ( mCursor ) ; if ( ch === '*' ) { mPage . ungetChar ( mCursor ) ; } } while ( NEGATIVE_1 !== ch && '/' !== ch ) ; } else { mPage . ungetChar ( mCursor ) ; } } } break ; case '\n' : comment = false ; break ; case '<' : if ( quoteSmart ) { if ( '' === quote ) { state = 1 ; } } else { state = 1 ; } break ; default : break ; } break ; case 1 : // < switch ( ch ) { case - 1 : done = true ; break ; case '/' : // tagName = 'textarea' // <textarea><div></div></textarea> /*
                             8.1.2.6 Restrictions on the contents of raw text and RCDATA elements

                             The text in raw text and RCDATA elements must not contain any occurrences
                             of the string '</' (U+003C LESS-THAN SIGN, U+002F SOLIDUS)
                             followed by characters that case-insensitively match the tag name of the element
                             followed by one of U+0009 CHARACTER TABULATION (tab),
                             U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR),
                             U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or U+002F SOLIDUS (/).
                             */ if ( ! tagName || mPage . getText ( mCursor . position , mCursor . position + tagName . length ) === tagName && ! mPage . getText ( mCursor . position + tagName . length , mCursor . position + tagName . length + 1 ) . match ( / \w / ) ) { state = 2 ; } else { state = 0 ; } break ; case '!' : ch = mPage . getChar ( mCursor ) ; if ( NEGATIVE_1 === ch ) { done = true ; } else if ( '-' === ch ) { ch = mPage . getChar ( mCursor ) ; if ( NEGATIVE_1 === ch ) { done = true ; } else if ( '-' === ch ) { state = 3 ; } else { state = 0 ; } } else { state = 0 ; } break ; default : state = 0 ; break ; } break ; case 2 : // </ comment = false ; if ( NEGATIVE_1 === ch ) { done = true ; } else if ( Utils . isLetter ( ch ) ) { // 严格 parser 遇到 </x lexer 立即结束 // 浏览器实现更复杂点，可能 lexer 和 parser 混合了 done = true ; // back up to the start of ETAGO // back up to the start of ETAGO mPage . ungetChar ( mCursor ) ; mPage . ungetChar ( mCursor ) ; mPage . ungetChar ( mCursor ) ; } else { state = 0 ; } break ; case 3 : // <! comment = false ; if ( NEGATIVE_1 === ch ) { done = true ; } else if ( '-' === ch ) { ch = mPage . getChar ( mCursor ) ; if ( NEGATIVE_1 === ch ) { done = true ; } else if ( '-' === ch ) { ch = mPage . getChar ( mCursor ) ; if ( NEGATIVE_1 === ch ) { done = true ; } else if ( '>' === ch ) { // <!----> <!--> state = 0 ; } else { // retreat twice , still begin to check --> mPage . ungetChar ( mCursor ) ; mPage . ungetChar ( mCursor ) ; } } else { // retreat once , still begin to check mPage . ungetChar ( mCursor ) ; } } // eat comment // eat comment break ; default : throw new Error ( 'unexpected ' + state ) ; } } end = mCursor . position ; return this . makeCData ( start , end ) ; }
parse cdata such as code in script
@private
@param quoteSmart if set true end tag in quote
(but not in comment mode) does not end current tag ( <script>x='<a>taobao</a>'</script> )
@param tagName
parse cdata such as code in script