Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Issue 701723007: Adding Element.closest() API (Closed)

Created:
6 years, 1 month ago by Paritosh Kumar
Modified:
5 years, 7 months ago
Reviewers:
Habib Virji, pdr.
CC:
arv+blink, blink-reviews, blink-reviews-dom_chromium.org, Inactive, dglazkov+blink, eae+blinkwatch, rwlbuis, sof
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

Adding Element.closest() API Implementing Element.closest() API according to specs https://dom.spec.whatwg.org/#dom-element-closest This API will parse selectors and if fails then throw SyntaxError else return closest ancestor that matches selectors if there is no ancestor that matches selectors, it will return nullptr. Blink-Dev Intent to Implement and ship Link : https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/yk_Fo6hyvb8 This patch is a merge from webkit http://trac.webkit.org/changeset/174324 by Dhi Aurrahman <diorahman@rockybars.com>". BUG=422731, 417603 R=habib.virji@samsung.com Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=185180

Patch Set 1 #

Total comments: 5

Patch Set 2 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+260 lines, -0 lines) Patch
A LayoutTests/fast/selectors/element-closest-general.html View 1 1 chunk +105 lines, -0 lines 0 comments Download
A LayoutTests/fast/selectors/element-closest-general-expected.txt View 1 1 chunk +52 lines, -0 lines 0 comments Download
A LayoutTests/fast/selectors/element-closest-scope.html View 1 1 chunk +46 lines, -0 lines 0 comments Download
A LayoutTests/fast/selectors/element-closest-scope-expected.txt View 1 chunk +28 lines, -0 lines 0 comments Download
M Source/core/dom/Element.h View 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/dom/Element.cpp View 1 chunk +8 lines, -0 lines 0 comments Download
M Source/core/dom/Element.idl View 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/dom/SelectorQuery.h View 2 chunks +2 lines, -0 lines 0 comments Download
M Source/core/dom/SelectorQuery.cpp View 2 chunks +17 lines, -0 lines 0 comments Download

Messages

Total messages: 12 (3 generated)
Paritosh Kumar
Please have a look.
6 years, 1 month ago (2014-11-11 09:24:04 UTC) #2
Paritosh Kumar
On 2014/11/11 09:24:04, Paritosh Kumar wrote: > Please have a look. Re-uploaded as per your ...
6 years, 1 month ago (2014-11-12 02:46:41 UTC) #3
pdr.
This looks much better, just a few comments below. https://codereview.chromium.org/701723007/diff/1/LayoutTests/fast/selectors/element-closest-general.html File LayoutTests/fast/selectors/element-closest-general.html (right): https://codereview.chromium.org/701723007/diff/1/LayoutTests/fast/selectors/element-closest-general.html#newcode26 LayoutTests/fast/selectors/element-closest-general.html:26: ...
6 years, 1 month ago (2014-11-12 03:13:18 UTC) #4
Paritosh Kumar
Thanks Updated as suggested. Please have a look. https://codereview.chromium.org/701723007/diff/1/LayoutTests/fast/selectors/element-closest-general.html File LayoutTests/fast/selectors/element-closest-general.html (right): https://codereview.chromium.org/701723007/diff/1/LayoutTests/fast/selectors/element-closest-general.html#newcode26 LayoutTests/fast/selectors/element-closest-general.html:26: <bar> ...
6 years, 1 month ago (2014-11-12 04:44:09 UTC) #6
pdr.
LGTM
6 years, 1 month ago (2014-11-12 04:47:27 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/701723007/40001
6 years, 1 month ago (2014-11-12 04:48:05 UTC) #9
commit-bot: I haz the power
Committed patchset #2 (id:40001) as 185180
6 years, 1 month ago (2014-11-12 05:57:00 UTC) #10
kozy
Will it work through shadow root? <div id='outside'> #shadow-root <div id='inside'></div> </div> docoument.getElementById('inside').closest('#outside') returns null. ...
5 years, 7 months ago (2015-05-13 03:40:20 UTC) #11
Paritosh Kumar
5 years, 7 months ago (2015-05-22 07:29:24 UTC) #12
Message was sent while issue was closed.
On 2015/05/13 03:40:20, kozyatinskiy wrote:
> Will it work through shadow root?
> <div id='outside'>
> #shadow-root
>   <div id='inside'></div>
> </div>
> docoument.getElementById('inside').closest('#outside') returns null. Is it
work
> as intended or not?

I'm not sure, this will return null.
As when I checked the same on 43.0.2357.65 (Official Build) m (32-bit), Blink:
@195283

with HTML:

<html>
<body>
<div id='outside'>
#shadow-root
  <div id='inside'></div>
</div>
<script>
console.log( document.getElementById('inside').closest('#outside'));
</script>
</body>
</html>

I got, 
<div id="outside">
#shadow-root
  <div id="inside"></div>
</div>

on console, as I'm expecting this also.
Same result found on FF also.

Not sure, may be, You got return value null because typo in
"docoument.getElementById('inside').closest('#outside')", docoument => document.

Powered by Google App Engine
This is Rietveld 408576698