Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Master odoo add prepend nby #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Goaman
Copy link
Contributor

@Goaman Goaman commented Jun 22, 2020

I need to prepend to an element in Odoo

@Goaman Goaman requested a review from Zynton June 22, 2020 14:25
packages/plugin-dom-helpers/src/DomHelpers.ts Outdated Show resolved Hide resolved
fromNode.prepend(toNode);
}
await this.editor.dispatcher.dispatchHooks('@redraw');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... the implementation is alright by me, but I have questions regarding the concept. We have moveBefore. Can't it already be used for that?
Like moveBefore(fromDomNode, toDomNode.firstChild) ? If it's specifically for nodes that don't have children yet, then why specifically prepend and not append ?
In any case, if you make a prepend, please also make a append :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that we do not want to check if there is a child or not.

@Zynton Zynton added the question Further information is requested label Jun 22, 2020
@Goaman Goaman force-pushed the master-odoo-add-prepend-nby branch 4 times, most recently from a0ef041 to 743fe86 Compare June 26, 2020 10:05
@Goaman Goaman requested a review from dmo-odoo June 26, 2020 10:06
@Goaman Goaman added awaiting review and removed question Further information is requested labels Jun 26, 2020
*
* @param params
*/
async prepend(fromDomNode: Node, toDomNode: Node): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what "prepend from" and "prepend to" mean. If I prepend "to a node" then I prepend inside this node ? Then toDomNode is the node in which the node is prepended ? Or I prepend "from" the node ? I have no idea what that means as I think this is not proper english. Obviously, append has the same problem. I suggest node and container for parameters. cc @Zinston if I'm just dumb by not understanding the english of "from" and "to" as prepositions for "prepend".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

@Goaman Goaman force-pushed the master-odoo-add-prepend-nby branch from 743fe86 to 3d22437 Compare June 26, 2020 11:52
*
* @param params
*/
async prepend(container: Node, node: Node): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed with @Zinston and the only proper way in english is to say "prepend X to Y" so we would switch the order of the parameters. Same for append, obviously.

Copy link
Contributor Author

@Goaman Goaman Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with the english argument. As we saw with sge and the command insertHTML, it is confusing to have to think about what english rule is for any command. It is far simpler to always set the node that will be modified as the first argument as 99% of our helpers.
It make sense to be like english only when it helps rather than create confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well actually either way node has to be first... insertHTML has the html to insert as first argument so prepend should have the node to insert as first argument as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, all other command except insertHTML has the "target" as the first argument. It's insertHTML that should have it's current argument changed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants