Skip to content

Commit

Permalink
chore: remove no longer used cloneNode implementation in nodeOps
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 27, 2022
1 parent aa70188 commit ab8bfac
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
9 changes: 0 additions & 9 deletions packages/runtime-dom/__tests__/nodeOps.spec.ts
@@ -1,15 +1,6 @@
import { nodeOps, svgNS } from '../src/nodeOps'

describe('runtime-dom: node-ops', () => {
test('the _value property should be cloned', () => {
const el = nodeOps.createElement('input') as HTMLDivElement & {
_value: any
}
el._value = 1
const cloned = nodeOps.cloneNode!(el) as HTMLDivElement & { _value: any }
expect(cloned._value).toBe(1)
})

test("the <select>'s multiple attr should be set in createElement", () => {
const el = nodeOps.createElement('select', false, undefined, {
multiple: ''
Expand Down
17 changes: 0 additions & 17 deletions packages/runtime-dom/src/nodeOps.ts
Expand Up @@ -52,23 +52,6 @@ export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
el.setAttribute(id, '')
},

cloneNode(el) {
const cloned = el.cloneNode(true)
// #3072
// - in `patchDOMProp`, we store the actual value in the `el._value` property.
// - normally, elements using `:value` bindings will not be hoisted, but if
// the bound value is a constant, e.g. `:value="true"` - they do get
// hoisted.
// - in production, hoisted nodes are cloned when subsequent inserts, but
// cloneNode() does not copy the custom property we attached.
// - This may need to account for other custom DOM properties we attach to
// elements in addition to `_value` in the future.
if (`_value` in el) {
;(cloned as any)._value = (el as any)._value
}
return cloned
},

// __UNSAFE__
// Reason: innerHTML.
// Static content here can only come from compiled templates.
Expand Down

0 comments on commit ab8bfac

Please sign in to comment.