Skip to content

Commit

Permalink
refactor(ui): replace HTMLDivElement with HTMLElement (#1385)
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji authored Jan 7, 2024
1 parent 09997af commit bd6f8c8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/varlet-ui/src/avatar/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export default defineComponent({
directives: { Lazy },
props,
setup(props) {
const avatarElement: Ref<HTMLDivElement | null> = ref(null)
const textElement: Ref<HTMLDivElement | null> = ref(null)
const avatarElement: Ref<HTMLElement | null> = ref(null)
const textElement: Ref<HTMLElement | null> = ref(null)
const scale: Ref<number> = ref(1)
onSmartMounted(getScale)
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/back-top/BackTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default defineComponent({
props,
setup(props) {
const show = ref(false)
const backTopEl = ref<HTMLDivElement | null>(null)
const backTopEl = ref<HTMLElement | null>(null)
const disabled = ref<TeleportProps['disabled']>(true)
let scroller: HTMLElement | Window
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/collapse-item/CollapseItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default defineComponent({
setup(props) {
const isShow = ref(false)
const showContent = ref(false)
const contentEl = ref<HTMLDivElement | null>(null)
const contentEl = ref<HTMLElement | null>(null)
const name = computed(() => props.name)
const disabled = computed(() => props.disabled)
const { index, collapse, bindCollapse } = useCollapse()
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/floating-panel/FloatingPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default defineComponent({
props,
setup(props) {
const visibleHeight = ref<number>(0)
const contentRef = ref<HTMLDivElement | null>(null)
const contentRef = ref<HTMLElement | null>(null)
const { height: windowHeight } = useWindowSize()
const defaultEndAnchor = computed(() => windowHeight.value * 0.6)
const anchor = useVModel(props, 'anchor')
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-ui/src/index-anchor/IndexAnchor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default defineComponent({
const ownTop = ref(0)
const disabled = ref(false)
const name = computed(() => props.index)
const anchorEl = ref<HTMLDivElement | RendererNode | null>(null)
const anchorEl = ref<HTMLElement | RendererNode | null>(null)
const { index, indexBar, bindIndexBar } = useIndexBar()
const { active, sticky, cssMode, stickyOffsetTop, zIndex } = indexBar
Expand All @@ -52,7 +52,7 @@ export default defineComponent({
ownTop.value = (anchorEl.value as RendererNode).$el
? (anchorEl.value as RendererNode).$el.offsetTop
: (anchorEl.value as HTMLDivElement).offsetTop
: (anchorEl.value as HTMLElement).offsetTop
}
function setDisabled(value: boolean) {
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-ui/src/index-bar/IndexBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default defineComponent({
props,
setup(props) {
const clickedName = ref<string | number>('')
const barEl = ref<HTMLDivElement | null>(null)
const barEl = ref<HTMLElement | null>(null)
const anchorNameList = ref<(number | string)[]>([])
const active = ref<number | string | undefined>()
const sticky = computed(() => props.sticky)
Expand Down Expand Up @@ -168,7 +168,7 @@ export default defineComponent({
async function setScroller() {
await doubleRaf()
scroller = getParentScroller(barEl.value as HTMLDivElement)
scroller = getParentScroller(barEl.value as HTMLElement)
}
function addScrollerListener() {
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/rate/Rate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default defineComponent({
function changeValue(score: number, event: MouseEvent) {
const { half, clearable } = props
const { offsetWidth } = event.target as HTMLDivElement
const { offsetWidth } = event.target as HTMLElement
if (half && event.offsetX <= Math.floor(offsetWidth / 2)) {
score -= 0.5
Expand Down
8 changes: 4 additions & 4 deletions packages/varlet-ui/src/slider/Slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default defineComponent({
props,
setup(props) {
const maxDistance = ref(0)
const sliderEl = ref<HTMLDivElement | null>(null)
const sliderEl = ref<HTMLElement | null>(null)
const isScroll = ref(false)
const scope = computed(() => toNumber(props.max) - toNumber(props.min))
const unitWidth = computed(() => (maxDistance.value / scope.value) * toNumber(props.step))
Expand Down Expand Up @@ -185,7 +185,7 @@ export default defineComponent({
onSmartMounted(() => {
if (!stepValidator() || !valueValidator()) return
maxDistance.value = (sliderEl.value as HTMLDivElement)[isVertical.value ? 'offsetHeight' : 'offsetWidth']
maxDistance.value = (sliderEl.value as HTMLElement)[isVertical.value ? 'offsetHeight' : 'offsetWidth']
})
onBeforeUnmount(() => {
Expand Down Expand Up @@ -307,7 +307,7 @@ export default defineComponent({
}
function start(event: TouchEvent, type: keyof ThumbsProps) {
if (!maxDistance.value) maxDistance.value = (sliderEl.value as HTMLDivElement).offsetWidth
if (!maxDistance.value) maxDistance.value = (sliderEl.value as HTMLElement).offsetWidth
if (!isDisabled.value) {
thumbsProps[type].active = true
}
Expand Down Expand Up @@ -362,7 +362,7 @@ export default defineComponent({
function click(event: MouseEvent) {
if (isDisabled.value || isReadonly.value) return
if ((event.target as HTMLDivElement).closest(`.${n('thumb')}`)) return
if ((event.target as HTMLElement).closest(`.${n('thumb')}`)) return
const offset = getOffset(event)
const type = getType(offset)
activeThumb = type
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-ui/src/time-picker/TimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default defineComponent({
components: { Clock },
props,
setup(props) {
const container = ref<HTMLDivElement | null>(null)
const container = ref<HTMLElement | null>(null)
const picker = ref<HTMLElement | null>(null)
const inner = ref<DefineComponent | null>(null)
const isInner = ref(false)
Expand Down Expand Up @@ -287,7 +287,7 @@ export default defineComponent({
}
function setCenterAndRange() {
const { left, top, width, height } = getRect(container.value as HTMLDivElement)
const { left, top, width, height } = getRect(container.value as HTMLElement)
center.x = left + width / 2
center.y = top + height / 2
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-ui/src/time-picker/clock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default defineComponent({
},
emits: ['update', 'change-prevent-update'],
setup(props, { emit }) {
const inner: Ref<HTMLDivElement | null> = ref(null)
const inner: Ref<HTMLElement | null> = ref(null)
const disableHour: Ref<Array<string>> = ref([])
const disable24HourIndex: Ref<Array<number>> = ref([])
Expand Down Expand Up @@ -203,7 +203,7 @@ export default defineComponent({
}
const getSize = () => {
const { width, height } = getRect(inner.value as HTMLDivElement)
const { width, height } = getRect(inner.value as HTMLElement)
return {
width,
Expand Down

0 comments on commit bd6f8c8

Please sign in to comment.