]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Include element in validationCallback
authorDaniel Imms <daimms@microsoft.com>
Thu, 9 Mar 2017 18:23:59 +0000 (10:23 -0800)
committerDaniel Imms <daimms@microsoft.com>
Thu, 9 Mar 2017 18:23:59 +0000 (10:23 -0800)
Fixes #591

src/Linkifier.test.ts
src/Linkifier.ts
src/Types.ts

index 012b1b6869b2cc4f9b7729f5f07779c1a681fd9a..97750c946651c27a720adf7d5b2f1c517a851737 100644 (file)
@@ -53,7 +53,7 @@ describe('Linkifier', () => {
     it('should enable link if true', done => {
       addRow('test');
       linkifier.registerLinkMatcher(/test/, () => done(), {
-        validationCallback: (url, cb) => {
+        validationCallback: (url, element, cb) => {
           cb(true);
           assert.equal((<HTMLElement>rows[0].firstChild).tagName, 'A');
           setTimeout(() => clickElement(rows[0].firstChild), 0);
@@ -65,7 +65,7 @@ describe('Linkifier', () => {
     it('should disable link if false', done => {
       addRow('test');
       linkifier.registerLinkMatcher(/test/, () => assert.fail(), {
-        validationCallback: (url, cb) => {
+        validationCallback: (url, element, cb) => {
           cb(false);
           assert.equal((<HTMLElement>rows[0].firstChild).tagName, 'A');
           setTimeout(() => clickElement(rows[0].firstChild), 0);
index a34edbc2fdd31a5768f03ca32ace1c6259bb6162..77cd16c19b22aebe1699eb95418c74672c143371 100644 (file)
@@ -160,7 +160,7 @@ export class Linkifier {
         const linkElement = this._doLinkifyRow(rowIndex, uri, matcher.handler, matcher.id === HYPERTEXT_LINK_MATCHER_ID);
         // Fire validation callback
         if (linkElement && matcher.validationCallback) {
-          matcher.validationCallback(uri, isValid => {
+          matcher.validationCallback(uri, linkElement, isValid => {
             if (!isValid) {
               linkElement.classList.add(INVALID_LINK_CLASS);
             }
index 9e8cd7623db0efff8e654fcc41d546eb05e2c7ac..896b729a8135857b10956c15e4753bcdea9f5245 100644 (file)
@@ -11,4 +11,4 @@ export type LinkMatcher = {
   priority?: number
 };
 export type LinkMatcherHandler = (event: MouseEvent, uri: string) => boolean | void;
-export type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;
+export type LinkMatcherValidationCallback = (uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => void;