* @description 元素变化 * @param newEle * @param oldEle * @param comment
(newEle, oldEle, comment, subscribe, unsubscribe)
| 1866 | * @param comment |
| 1867 | */ |
| 1868 | function handleChangeElement(newEle, oldEle, comment, subscribe, unsubscribe) { |
| 1869 | if (newEle && oldEle) { |
| 1870 | const { beforeMount, onMounted } = newEle; |
| 1871 | if (beforeMount || onMounted) { |
| 1872 | subscribe && subscribe(newEle); |
| 1873 | } |
| 1874 | oldEle.ele.replaceWith(newEle.ele); |
| 1875 | return; |
| 1876 | } |
| 1877 | if (newEle && !oldEle) { |
| 1878 | const { beforeMount, onMounted } = newEle; |
| 1879 | if (beforeMount || onMounted) { |
| 1880 | subscribe && subscribe(newEle); |
| 1881 | } |
| 1882 | comment.replaceWith(newEle.ele); |
| 1883 | return; |
| 1884 | } |
| 1885 | if (!newEle && oldEle) { |
| 1886 | unsubscribe && unsubscribe(oldEle); |
| 1887 | oldEle.ele.replaceWith(comment); |
| 1888 | return; |
| 1889 | } |
| 1890 | } |
| 1891 | /** |
| 1892 | * @description 创建文字节点 |
| 1893 | * @param text |
no test coverage detected